MOSCOW — The world this weekend celebrated the 70th anniversary of the defeat of Nazi Germany. So a day after the big party, why was Russian President Vladimir Putin praising an agreement between the Soviet Union and the Nazis that helped spark World War II?

That’s what he did standing next to German Chancellor Angela Merkel in Moscow on Sunday after the two leaders solemnly honored the toll of the war.

“When the Soviet Union realized that it was left to face Hitler’s Germany on its own, it acted to try to avoid a direct confrontation, and this resulted in signing the Molotov-Ribbentrop Pact,” Putin told a reporter on Sunday who asked about the agreement. “This pact did make sense in terms of guaranteeing the Soviet Union’s security.”

Putin, who earlier in his 15 years in power called the deal “immoral,” has been rehabilitating Soviet history in recent years, even the uncomfortable bits. The latest revision has descended upon the 1939 deal that split Eastern Europe between the Soviet Union and Nazi Germany.

The bargain, with its notions of spheres of influence, has taken on special resonance after a year of conflict in Ukraine. Russia has firmly asserted that Ukraine has no business moving toward Europe — and it has backed rebels in eastern Ukraine to ensure that it doesn’t happen.

During the Soviet era, the official line was that Stalin had little choice but to agree to a treaty of non-aggression with Nazi Germany because he had been spurned by France and Britain in his bid to create an anti-fascist alliance.

But that ignored the existence of a secret addendum to the deal that awarded Eastern Europe to the Soviet Union. The addendum was so incendiary that Russia formally acknowledged its existence only in the 1990s. It paved the way for the Soviet Union’s later domination of Eastern European nations — and it meant that Stalin was caught napping in 1941 when Hitler launched a surprise attack on the Soviet Union.

World War II came at an unparalleled cost for the Soviet Union, where historians estimate 27 million people died, far more than in any other nation. The country’s enormous sacrifices were critical to turning the Nazi tide and winning in Europe. The pain was nearly universal. Hundreds of thousands of people turned out in Moscow on Saturday to march with photographs of loved ones who died during the war.

But historians say the Molotov-Ribbentrop Pact helped exacerbate the Soviet losses, starting in 1941 because the Kremlin was caught snoozing as Hitler’s troops drew up to the Soviet border.

And for the nations of Eastern Europe, including Poland, the Baltics and others, the pact meant that the conclusion of World War II marked an end to one form of cruel domination and the beginning of another.

That’s why Merkel couldn’t help but jump in on Sunday after Putin praised the pact, even though the question wasn’t directed to her.

“From my perspective, the Molotov-Ribbentrop Pact is very difficult to understand if one doesn’t also keep in mind the secret addendum,” she said, drawing a sour look from Putin. “From this perspective, I believe this was an agreement that was born out of an injustice.”