Before the establishment of electricity spot market, China’s medium and long-term electricity market was still pure electricity trading. Therefore, the reasonable design of the deviation treatment and settlement method of the contract electricity quantity is conducive to the smooth transition from the medium and long-term electricity trading to the spot market. To improve the accuracy of the deviation settlement of medium and long-term electricity transactions and achieve a better link between the spot market and power enterprises, the analysis and research of the deviation settlement mechanism of medium and long-term electricity transactions under the spot environment are carried out in the paper. Based on the spot market environment, the optimal division model of the electricity delivery time is established. Based on the model, the product portfolio of medium and long-term electricity transactions is determined. With financial balance as the goal, the establishment conditions of settlement mechanism are set. Finally, the establishment of the deviation contract settlement mechanism authorized by the government is completed. The new settlement mechanism is applied to an electric power enterprise, which improves the accuracy of the medium and long-term transaction deviation settlement, and ensures the fairness and rationality of the medium and long-term transaction.