Get breaking news alerts and special reports. The news and stories that matter, delivered weekday mornings.

The United States killed a high-profile commander of Iran's secretive Quds Force with a drone strike in Iraq early Friday, the Department of Defense said.

"At the direction of the President, the U.S. military has taken decisive defensive action to protect U.S. personnel abroad," the department said in a statement announcing the death of Gen. Qassem Soleimani, a commander of Iran's military forces in Iraq, Syria, Lebanon and elsewhere throughout the Middle East.

The deadly airstrike will raise tensions between the U.S. and Iran, which were already heightened by the New Year's attacks on the U.S. Embassy compound in Baghdad.

Another man, Abu Mahdi al-Muhandis, said to be the deputy of the militias known as the Popular Mobilization Units and a close adviser to Soleimani, was also killed in the airstrike near Baghdad's airport, according to Iraqi television reports. The PMU tweeted that al-Muhandis and Soleimani were killed when their vehicle was hit on the road to the airport.

In the past, the United States has credited Soleimani's militias with combating a U.S. enemy in Iraq, the Islamic State militant group. Soleimani's Quds Force was a division of Iran's Revolutionary Guard, widely believed to support many terrorist groups, such as Hezbollah.

"This strike was aimed at deterring future Iranian attack plans," the Defense Department said in its statement. "The United States will continue to take all necessary action to protect our people and our interests wherever they are around the world."

The Pentagon said Soleimani had been actively developing plans to attack U.S. diplomats and service members in Iraq and elsewhere throughout the region.

His death comes after rioters tried for two days to scale the fortress-like walls at the United States' largest embassy. They retreated under a show of force from the Pentagon; 100 Marines were airlifted into the compound, and about 700 more Army paratroopers are expected soon in Kuwait from a global response force based at Fort Bragg, North Carolina.

Earlier, Secretary of Defense Mark Esper threatened a preemptive strike against Iranian militias if there were any renewed attacks against U.S. personnel or interests in Iraq. The chairman of the Joint Chiefs of Staff told reporters that attackers would run into a buzz saw.

The U.S. strike comes amid heightened tensions between the United States and Iran over rocket attacks in Iraq that U.S. officials had blamed on Iranian-backed forces, as well as the attempted breach of the embassy compound in Baghdad.

The conflict at the embassy occurred after U.S. fighter jets struck weapons depots in Iraq and Syria that the United States said were linked with a group called Kataeb Hezbollah, which it blames for attacks on bases of the U.S.-led coalition fighting ISIS in recent months.

At least 25 militia fighters were killed in the airstrikes. The strikes followed the death of a U.S. contractor who was killed Dec. 27 in a rocket attack on an Iraqi military base in Kirkuk that also hosted coalition forces. Several U.S. service members were also injured.

The Defense Department said in announcing the strike Thursday night that Soleimani had orchestrated attacks on coalition bases in Iraq over several months, including the Dec. 27 attack that killed the contractor.

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

He "also approved the attacks on the U.S. Embassy in Baghdad that took place this week," the department said in the statement.

Download the NBC News app for breaking news

Iranian Foreign Minister Javad Zarif called the U.S. action "an extremely dangerous and foolish escalation."

"The U.S. bears responsibility for all consequences of its rogue adventurism," Zarif wrote on Twitter.

Iran is likely to retaliate with terrorism and cyberattacks, said Norman Roule, a 34-year CIA veteran who oversaw national intelligence policy on Iran before he retired in 2017.

Roule said in a telephone interview that the U.S. move puts Washington and Tehran in a confrontation unlike any other since the hostage crisis in 1979.

"I believe it is highly likely the U.S. would not have undertaken this action unless it believed doing so would have prevented the loss of American lives," Roule said. "American officials are fully aware of the consequences such an action would produce."

The former head of Iran’s Islamic Revolutionary Guard Corps, Mohsen Rezaee, vowed “strong revenge against the United States” on Twitter.

Early Friday, the Department of State urged Americans to leave Iraq immediately.

Trump has not directly addressed Soleimani's death but tweeted a picture of the American flag after news of his death broke, and tweeted Friday morning that "Iran never won a war, but never lost a negotiation!"

This photo released by the Iraqi Prime Minister Press Office shows a burning vehicle at the Baghdad International Airport following an airstrike, in Baghdad, Iraq, on Jan. 3, 2020. Iraqi Prime Minister Press Office via AP

Earlier this week, when asked about the possibility of war with Iran, Trump said: "I don't see that happening. No, I don't think Iran would want that to happen."

"I want to have peace. I like peace. And Iran should want peace more than anybody," Trump told reporters at his New Year's Eve event at Mar-a-Lago in Florida.

At least one lawmaker expressed alarm at the action.

Sen. Chris Murphy, D-Conn., a member of the Senate Foreign Relations Committee, tweeted: "Soleimani was an enemy of the United States. That's not a question."

"The question is this — as reports suggest, did America just assassinate, without any congressional authorization, the second most powerful person in Iran, knowingly setting off a potential massive regional war?" Murphy said in the tweet.

Sen. Marco Rubio, R-Fla., also a member of the Senate Foreign Relations Committee, tweeted that the United States and Trump "exercised admirable restraint while setting clear red lines & the consequences for crossing them" after what he said were repeated attacks by the Revolutionary Guard.

"#Iran's Quds Force chose the path of escalation," Rubio said in the tweet. "They are entirely to blame for bringing about the dangerous moment now before us."

Sen. Ben Sasse, R-Neb., a member of the Senate Intelligence Committee, said in a statement: "This is very simple: General Soleimani is dead because he was an evil b------ who murdered Americans." Sasse said "the president made the brave and right call."

Sen. Tom Cotton, R-Ark., said in a statement that Soleimani "masterminded Iran's reign of terror for decades, including the deaths of hundreds of Americans."

"Tonight, he got what he richly deserved, and all those American soldiers who died by his hand also got what they deserved: justice,” Cotton said, adding that America is safer with the Quds commander dead.

The Trump administration announced in April that it was designating the Revolutionary Guard a foreign terrorist organization, which is the first time the United States had used that designation on part of another country's government.

Since then, there have been several tense incidents involving the United States and Iran, including one in June, when Iran shot down a U.S. surveillance drone that the Revolutionary Guard said had entered Iranian airspace. U.S. Central Command said the aircraft was in international airspace.

The Trump administration also blamed Iran for an attack in September on oil sites in Saudi Arabia, which prompted the United States to deploy military forces to the Middle East that Esper said at the time would be defensive in nature.

Al-Muhandis, the militia official who was killed Thursday, had been accused of plotting attacks on the United States since the 1980s. He was convicted in absentia and sentenced to death by Kuwait for his role in the 1983 attacks on the U.S. and French embassies in Kuwait, in which five Kuwaitis were killed.

The Treasury Department cited al-Muhandis' role in the embassy attack in naming him a Specially Designated National, part of a list of terrorists subject to U.S. sanctions. That designation also said he took part in an assassination attempt on the emir of Kuwait in the early 1980s.