The substantial performance doctrine is a legal principle in contract law that allows a party to enforce a contract even if they have not fully performed all their obligations, as long as the essential purpose of the contract has been achieved. This doctrine helps to ensure fairness in situations where minor breaches or incomplete work do not significantly impair the overall value of the contract. It plays a crucial role in construction and real estate contracts, where it can determine the rights to payment despite some uncompleted aspects of the work.