WASHINGTON — President Trump was deep in discussion with political advisers going over campaign plans at his Mar-a-Lago estate in Florida just before 5 p.m. Thursday when he was abruptly summoned to another meeting. A while later, he returned just as mysteriously, jumping back into the conversation without offering a clue to what was going on.

In those few minutes, according to multiple people briefed on the events, Mr. Trump had made one of the most consequential foreign policy decisions of his presidency, giving final authorization to a drone strike halfway around the world that would eliminate one of America’s deadliest enemies while pushing the United States to the edge of an escalating confrontation with Iran that could transform the Middle East.

The military operation that killed Maj. Gen. Qassim Suleimani, the Iranian security and intelligence commander responsible for the deaths of hundreds of American troops over the years, was unlike the ones that took out Osama bin Laden or Abu Bakr al-Baghdadi, terrorist leaders caught after long manhunts. General Suleimani did not have to be hunted; a high-ranking official of the Iranian government, he was in plain sight for years. All that was required was a president to decide to pull the trigger.

Presidents George W. Bush and Barack Obama never did. Mr. Bush’s administration made a conscious decision not to kill General Suleimani when he was in the cross hairs, and Mr. Obama’s administration evidently never made an effort to pursue him. Both reasoned that killing the most powerful general in Iran would only risk a wider war with the country, alienating American allies in Europe and the Middle East and undermining the United States in a region that had already cost plenty of lives and treasure in the past two decades.

But Mr. Trump opted to take the risk they did not, determined to demonstrate after months of backing down after previous Iranian provocations that he would no longer stand by while General Suleimani roamed freely. “He should have been taken out many years ago!” Mr. Trump wrote on Twitter on Friday.

The question was why now? “This guy has been killing Americans in Iraq since 2003,” said Jon Soltz, the chairman of VoteVets.org and an Iraq war veteran. “I was in one of his attacks in Taji in 2011. They were dropping 240-millimeter rockets on us. So this is not a surprise that he’s involved in killing Americans.”

“But the question is what was different last night?” he added. “The onus is on Trump to prove something was different, or this is no different than another weapons of mass destruction play.”

Aides said Mr. Trump was angry about a rocket attack last week by forces linked to Tehran that killed an American civilian contractor and stewed as he watched television images of pro-Iranian demonstrators storming the American Embassy in Baghdad in the days that followed, neither of which would normally result in such a seemingly disproportionate retaliation.

But senior officials said the decision to target General Suleimani grew out of a new stream of Iran threats to American embassies, consulates and military personnel in Syria, Iraq and Lebanon. General Suleimani had just left Damascus, the Syrian capital, where he was planning an “imminent” attack that could claim hundreds of lives, officials said.

“We’d be negligent if we didn’t respond,” Gen. Mark A. Milley, the chairman of the Joint Chiefs of Staff, told reporters on Friday in his Pentagon office. “The threat of inaction exceeded the threat of action.”

Still, officials offered scant details and only general explanations for why these reported threats were any different from the rocket attacks, roadside bombings and other assaults carried out by General Suleimani’s Quds Force of the Islamic Revolutionary Guards Corps over the years. “Size, scale and scope,” General Milley said without elaboration.

National security experts and even other officials at the Pentagon said they were unaware of anything drastically new about Iranian behavior in recent weeks; General Suleimani has been accused of prodding Shiite militias into attacking Americans for more than a decade.

The drone strike came at a charged time for Mr. Trump, who faces a Senate trial after being impeached by the House largely along party lines last month for abuse of power and obstruction of Congress. While advisers insisted politics had nothing to do with the decision, the timing was bound to raise questions in an era marked by deep suspicion across party lines.

General Suleimani was not a particularly elusive target. Unlike Bin Laden or al-Baghdadi, he moved about quite freely in a number of countries, frequently popping up meeting with Iranian allies or visiting front-line positions in Syria, Iraq and Lebanon. He traveled with an air of impunity. His fans distributed photographs of him on social media, and he occasionally gave interviews. One former senior American commander recalled once parking his military jet next to General Suleimani’s plane at the Erbil airport in northern Iraq.

“Suleimani was treated like royalty, and was not particularly hard to find,” said Marc Polymeropoulos, a former senior C.I.A. operations officer with extensive counterterrorism experience overseas. “Suleimani absolutely felt untouchable, particularly in Iraq. He took selfies of himself on the battlefield and openly taunted the U.S., because he felt safe in doing so.”

That public profile made him the face of the Iranian network across the Middle East, the so-called Axis of Resistance, which includes groups like Hezbollah in Lebanon, Hamas in Gaza, the Houthis in Yemen and a range of militias in Syria and Iraq who share Iran’s animosity toward Israel and the United States. General Suleimani wanted to show that he could be anywhere and everywhere, an American official said, knowing he could be a target but obsessed with proving he had his hand in everything.

If General Suleimani acted untouchable, for years he was. One night in January 2007, American Special Operations commandos tracked him traveling in a convoy from Iran into northern Iraq. But the Americans held their fire and General Suleimani slipped away into the darkness.

“To avoid a firefight, and the contentious politics that would follow, I decided that we should monitor the caravan, not strike immediately,” Gen. Stanley A. McChrystal, then the head of the secretive Joint Special Operations Command, recalled in an article last year.

Until now, Mr. Trump had shied away from military action against Iran, too. While he talked tough after Iran was blamed for various attacks on oil tankers in the Gulf of Oman and oil facilities in Saudi Arabia, Mr. Trump declined to use force, at one point even calling off a planned airstrike with only 10 minutes to go.

An American official who asked not to be identified discussing internal deliberations said the president’s advisers worried that he had indicated so many times that he did not want a war with Iran that Tehran had become convinced that the United States would not act forcibly. But the official acknowledged that the strike was a huge gamble and could just as likely prompt an outsize reaction from both Iran and Iraq.

The operation culminated three years of rising tension since Mr. Trump took office and followed through on his pledge to withdraw from the nuclear agreement that Mr. Obama brokered with Iran in 2015. As part of a “maximum pressure” campaign, Mr. Trump reimposed sanctions on Tehran to strangle its economy while Iran tested the American president with a string of provocative actions.

The mission to target General Suleimani was set in motion after a rocket attack last Friday on an Iraqi military base outside Kirkuk killed an American civilian contractor, according to senior American officials. The military’s Special Operations Command spent the next several days looking for an opportunity to hit General Suleimani. Military and intelligence officials said the strike drew on information from secret informants, electronic intercepts, reconnaissance aircraft and other surveillance tools.

The option that was eventually approved depended on General Suleimani’s arrival at Baghdad International Airport. If he was met by Iraqi officials, one American official said, the strike would be called off. But the official said it was a “clean party” and the strike was authorized.

Mr. Trump, who was spending the holiday season at Mar-a-Lago, participated in multiple meetings on the operation, and aides said that he did not struggle with the decision, unlike over the summer when he changed his mind citing possible civilian casualties. “It was a very straightforward decision by the president to make the call on this,” Robert C. O’Brien, his national security adviser, told reporters.

As late as Thursday, officials were still weighing other, less inflammatory options, including strikes against Iranian ships, missile batteries or militias in Iraq, one official said. But aides noted that Mr. Trump has grown wary of warnings that bold actions will result in negative consequences because in some cases those have not materialized, notably in his trade war.

The president kept the discussions to a tight circle that included Mr. O’Brien; Secretary of State Mike Pompeo; Defense Secretary Mark T. Esper; Gina Haspel, the C.I.A. director; Mick Mulvaney, the acting White House chief of staff; and Eric Ueland, the president’s legislative liaison. Left out of the loop was the White House communications operation.

Mr. Pompeo has been one of the administration’s most persistent Iran hawks and the public face of the sanctions campaign, but until now, he had never persuaded the president to take military action.

As a congressman, Mr. Pompeo assailed the former secretary of state Hillary Clinton over the deadly attack on an American diplomatic post in Benghazi, Libya, and he has been obsessed with embassy security in the Middle East, and in Iraq in particular, according to former officials and associates. The violent protests in recent days at the American Embassy in Baghdad spooked the secretary, officials said, prompting him to cancel an important trip to Ukraine.

The administration said the strike was legal under the 2002 act of Congress authorizing the invasion of Iraq and also a matter of self-defense under international law and pursuant to the president’s constitutional powers as commander in chief. “We had the right to self-defense,” Mr. O’Brien said.

The strike was particularly unusual in that it targeted a top official in a national government. Since the late 1970s, an executive order has banned “assassinations.” But that constraint, while still in place on paper, has eroded in the fight against terrorism. Legal teams under presidents of both parties have argued that the term “assassination,” which is not defined by federal law or the order, does not cover killing terrorists and other people deemed to pose an imminent threat to the United States because that would instead be self-defense.

Against that backdrop, it may be relevant that last year, Mr. Trump designated the Islamic Revolutionary Guards Corps as a foreign terrorist organization — the first time that the United States had so designated part of another nation’s government.

However the lawyers rationalized it, General McChrystal, who passed on taking the shot at General Suleimani 13 years ago, said Mr. Trump was right to take it now. “The targeting was appropriate given Suleimani’s very public role in orchestrating Iranian attacks on the U.S. and our allies,” he said in an email.

But the general added a somber warning: “We can’t consider this as an isolated action. As with all such actions it will impact the dynamics of the region, and Iran will likely feel compelled to respond in kind. There is the potential for a stair-step escalation of attacks and we must think several moves ahead to determine how far we will take this — and what the new level of conflict we are prepared to engage in.”

Eric Schmitt, Helene Cooper, Thomas Gibbons-Neff and Peter Baker reported from Washington, and Maggie Haberman from Palm Beach, Fla. Edward Wong and Charlie Savage contributed reporting from Washington, and Ben Hubbard from Beirut, Lebanon.