In 2011 and 2012, Donald Trump repeatedly accused President Barack Obama of seeking war with Iran to help win the 2012 presidential election.

"In order to get elected, @BarackObama will start a war with Iran," Trump tweeted in 2011, years before he began his own presidential campaign.

On Thursday, Trump ordered the killing of Qassem Soleimani, a top Iranian military commander who was one of the most powerful men in the Middle East.

The assassination came with Trump's approval rating mired at 42% and with him facing removal from office through impeachment in a US election year.

Visit Business Insider's homepage for more stories.

Tweets from back in 2011 and 2012 in which Donald Trump predicted that President Barack Obama would start a war with Iran to secure his reelection have gone viral after the US assassinated a top Iranian general, dramatically escalating its confrontation with Iran.

Trump personally ordered the killing by airstrike of Iranian Maj. Gen. Qassem Soleimani, who is believed to have died in the early hours of Friday near an airport in Baghdad.

The Pentagon said Soleimani, who led the Quds Force and was one of the most powerful men in the Middle East, "was actively developing plans to attack American diplomats and service members in Iraq and throughout the region."

Trump's only statement was to tweet a picture of the US flag.

Despite Trump's evident pride at the attack, many on social media seized on his previous posts where, with Obama in the White House, Trump had condemned the idea of military action against Iran as foolish electioneering.

Trump, then best known as a reality-TV star and real-estate developer, hammered home the point in a 2011 video filmed in his Trump Tower office.

After Obama won reelection, Trump continued to accuse him of seeking war with Iran.

Trump's attacks on Obama's Iran policy came amid heightened tensions over Iran's nuclear program, which the Obama administration had sought to halt.

Israel, a key US ally in the Middle East, had threatened airstrikes meant to cripple Iran's nuclear program. But with Obama having pledged to limit US entanglement in foreign conflicts, the administration was wary of conflict with Iran.

During his second term Obama sought rapprochement with Iran and its new reformist president, Hassan Rouhani, successfully negotiating the Iran nuclear deal that saw Iran halt its nuclear program in exchange for sanctions relief.

During Trump's three years in power tensions with Iran have escalated, with the president scrapping the nuclear deal in 2018 and introducing new, punishing sanctions.

The Pentagon has blamed a series of attacks on the US and its allies on Iran, culminating in an attack on the US Embassy in Baghdad on Tuesday by protesters from an Iran-backed militia.

Trump's approval rating is languishing at 42.4%, according a model by FiveThirtyEight, and he is the first US president to face an impeachment trial while running for reelection.

The most recent president to be impeached, Bill Clinton, also faced accusations of launching a foreign military strike to distract voters from his domestic political woes.

Back in December 1998, Clinton authorized airstrikes against Iraq, then controlled by Saddam Hussein, only a day after the House of Representatives accused him of "high crimes and misdemeanors" in relation to his affair with the White House intern Monica Lewinsky.