I am trying to understand the difference between paxos and two phase commit as means to reach consensus among multiple machines. Two phase commit and three phase commit is very
2-PC is the most traditional transaction commit protocol and powers the core of atomicity of transactions. But it is blocking in nature, i.e. if the transaction manager/coordinator fails in between, it will cause the protocol to block and no process will be aware of it. It requires manual intervention to repair the coordinator.
While Paxos being a distributed consensus protocol has multiple such coordinators and if a majority of the coordinators agree to the transaction completion, it becomes a successful atomic transaction.
You should read https://www.microsoft.com/en-us/research/wp-content/uploads/2016/02/tr-2003-96.pdf to understand how these two protocols are differentiated in a more granular manner. In the same paper, Gray and Lamport also introduce a protocol i.e. a combination of Paxos and 2-PC for faster performance.
2PC blocks if the transaction manager fails, requiring human intervention to restart. 3PC algorithms (there are several such algorithms) try to fix 2PC by electing a new transaction manager when the original manager fails.
Paxos does not block as long as a majority of processes (managers) are correct. Paxos actually solves the more general problem of consensus, hence, it can be used to implement transaction commit as well. In comparison to 2PC it requires more messages, but it is resilient to manager failures. In comparison to most 3PC algorithms, Paxos renders a simpler, more efficient algorithm (minimal message delay), and has been proved to be correct.
Gray and Lamport compare 2PC and Paxos in an excellent paper titled "Consensus on Transaction Commit".
(In the answer of peter, I think he is mixing 2PC with 2PL (two-phase locking).)