The two phase commit protocol is a distributed algorithm that allows all nodes in a distributed system to agree on committing or aborting a transaction, even in the case of site failures or message losses. It involves two phases - in phase 1 the coordinator sends a commit or abort message to cohorts, and cohorts respond with their agreement or disagreement. In phase 2, if all cohorts agree the coordinator sends a commit, otherwise it sends an abort. The protocol guarantees that all nodes will either commit or abort the transaction.