A transaction is started, and some work is performed.
Once the work is finished, the two-phase commit begins.
The coordinator (transaction manager) of the transaction asks each resource taking part in the transaction whether it is prepared to commit.
If all resources respond positively, the coordinator instructs the resources to make all work performed durable (usually committed to a database).
If not, all work performed is rolled back (undone) such that the underlying data structures are in their original states.