A quasi-contract is a retroactive agreement between two parties who have no prior commitments to each other. A court creates it to remedy a situation in which one party gains something at the expense of the other.