“This will not be a Benghazi,” vowed President Donald Trump to reporters on New Year’s Eve. “This will never, ever be a Benghazi.”

A spot-on analogy. So far, so good. It looks like a seizure of the U.S. embassy in Baghdad by Iranian militants has been averted. In so doing, President Trump — with full credit to our troops — has averted not only a Benghazi but a Jimmy Carter.

The parallels between what happened in the Middle East the final week of December 2019 and what happened in the Middle East the final weeks of 1979 are chilling. Iranian agitators marched on the U.S. embassy in Baghdad almost 40 years to the day that the Soviet Red Army marched into Afghanistan, a disastrous event that came on the heels of Iranian militants seizing the U.S. embassy in Tehran a few weeks earlier. The events were calamitous, including for President Jimmy Carter, who was seeking reelection.

On November 4, 1979, Iranian extremists stormed the U.S. embassy in Tehran, seizing 66 hostages, 52 of which would be held for over a year. 444 days, to be exact.

Then came a Christmas-time shocker. Late December 1979, the Soviets rolled into Afghanistan. It was Moscow’s first direct military intervention outside the Warsaw Pact since World War II, and another striking sign of the Kremlin’s aggression. Nearly a dozen countries had fallen into the Soviet orbit from 1974 to 1979. America was losing the Cold War.

President Jimmy Carter learned of the Soviet invasion while celebrating Christmas with his family in the White House. Just six months earlier he had literally kissed Leonid Brezhnev on the cheek in Vienna. Brezhnev betrayed him with that kiss.

Carter’s initial reaction to the Soviet invasion did nothing to inspire confidence or slow his slide in opinion polls. In a television interview six days later, he said: “My opinion of the Russians has changed most dramatically in the last week…. This action of the Soviets has made a more dramatic change in my own opinion of what the Soviets’ ultimate goals are than anything they’ve done in the previous time I’ve been in office.” His remark was viewed as dangerously naïve, as a form of on-the-job education unacceptably late for a president. Ronald Reagan, who would challenge him for the presidency, privately said that Carter’s assessment “would be laughable, I think, if it were not so tragic.” Reagan added: “It is frightening to hear a man in the office of the presidency who has just discovered that the Soviets can’t be trusted, that they’ve lied to him.”

It was indeed.

The domestic situation wasn’t much better for Carter. The economy was a nightmare, underscored by the “misery index.” Unemployment and inflation were at double-digits. Interest rates approaching 20 percent nearly halted home buying. An energy crisis wrought soaring gas prices and queues during a nasty winter. The nation faced its worst economic situation since the Great Depression. Then came Iran and Afghanistan.

Carter was in trouble. Sensing blood in the water, a Democrat shark by the name of Senator Ted Kennedy began sizing up Carter for a challenge in the Democratic Primary.

Carter looked to salvage something on April 24, 1980, when he ordered a dramatic rescue mission in Iran. By then, American hostages had been held for six months at the U.S. embassy. Exasperated, Carter authorized a risky operation. “I do not want to undertake this operation,” he told his military brass, “but we have no other recourse…. We’re going to do this.” Carter later wrote in his memoirs that it was time “to bring our hostages home; their safety and our national honor were at stake.”

Carter’s plan called for a complex two-night operation involving hundreds of varied personnel, including the elite Delta Force and its 132 commandos, and a unit of Army Rangers. Forty-four aircraft would be deployed among six different locations, including critical RH-53 helicopters and C-130 Hercules transports rigged with temporary 18,000-gallon fuel tanks.

How did it go? It was a complete failure. It was a “calamity heaped on despair,” recalled Colonel James Kyle, the on-scene commander. “It was devastating.” He called it “the most colossal episode of hope, despair, and tragedy” he had experienced in nearly three decades of military service.

At 7:00 a.m. the next day, Carter informed a sleepy nation that eight of its servicemen had just died in a secret rescue operation. The ordeal was dubbed Desert One. It became a metaphor for a military fiasco.

It was arguably worse than Benghazi.

Ironically, the presidential election would be held November 4, 1980, the one-year anniversary of the seizure of the U.S. embassy in Iran. Carter lost 44 of 50 states to Ronald Reagan. Reagan crushed him in the popular vote, 51-41 percent, and won the Electoral College 489-49.

No one knows, of course, how President Trump will fare in his reelection bid in November. But this much we know already: he will not be facing a hostage situation at the hands of Iranians at our embassy. Donald Trump has averted a Benghazi, and he may have averted a Jimmy Carter as well.