X3DH is a key agreement protocol that establishes shared secret keys between two parties using asynchronous cryptography, enabling offline messaging and forward secrecy. The protocol involves Alice, Bob, and a server, using elliptic curve Diffie-Hellman functions with X25519 or X448 curves for mutual authentication and encrypted communication.