HMAC is a hash-based message authentication code used to verify the integrity and authenticity of a message. It combines a secret key with a hash function to ensure the message has not been tampered with during transmission and to authenticate the sender.