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

Iraqi protesters withdrew from the perimeter of the U.S. Embassy compound in Baghdad on the second day of demonstrations against deadly U.S. airstrikes last weekend, U.S. officials said.

"All protesters withdrew from the area in front of the US embassy and left the Green Zone. The embassy is now completely surrounded and secured by security forces," the Joint Operation Command said Wednesday.

Earlier Wednesday, U.S. security forces had fired tear gas into the crowd.

Supporters and members of the Hashd al-Shaabi paramilitary force demonstrate outside the U.S. Embassy complex in Baghdad on Wednesday. Ahmad Al-Rubaye / AFP - Getty Images

"The situation around Embassy Baghdad has improved," a State Department spokesperson said Wednesday. "We appreciate the effective measures the Government of Iraq has taken to improve the situation and to prevent further attacks against our diplomatic mission."

The pro-Iran protesters had camped outside the gates of the embassy overnight after thousands stormed the compound on Tuesday, with some making it as far as the main reception area before failing to gain access to the main building. The Joint Operation Command said protesters had burned and broken doors to the reception room.

The diplomatic building sits on a vast 100-acre site along the Tigris River, making it the United States' biggest embassy.

Defense Secretary Mark Esper announced Tuesday that the United States was sending about 750 soldiers to the Middle East in the wake of the embassy's storming. More personnel were on standby to deploy if needed, he said.

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

On Wednesday, 250 to 300 protesters gathered outside the compound walls, where Iraqi security forces had also assembled to protect the integrity of the embassy, a senior Iraqi security official told NBC News on condition of anonymity.

Video circulated on social media that appeared to show protesters scaling a compound building, and agencies published video of what appeared to be demonstrators throwing stones at embassy buildings. It was unclear whether the protesters were militia members, their supporters or both.

The protesters were demonstrating against deadly U.S. airstrikes Sunday on weapons depots in Iraq and Syria that the United States said were linked to an Iran-backed Shiite militia group, Kataeb Hezbollah. At least 25 fighters were killed in the strikes.

The United States blames the militia for attacks in recent months on the bases of the U.S.-led coalition that is fighting the Islamic State.

Download the NBC News app for breaking news

Kataeb Hezbollah, also known as the Hezbollah Brigades in Iraq, is separate from the Lebanese militant group Hezbollah. It operates under the umbrella of the state-sanctioned militias, known collectively as the Popular Mobilization Forces.

''The American troops in Iraq are supposed to either train Iraqi forces or to combat terrorism. But the killing of members of the Hashd al-Shaabi [Popular Mobilization Forces], this is something unacceptable," Mohamed Al-Haydari, the director of doctrinal guidance for the forces, told Reuters.

"So, for this reason, we are coming here, until the U.S. troops leave Iraq," he added.

Iraqi security forces stand guard outside the U.S. Embassy in Baghdad on Wednesday. Ahmad Al-Rubaye / AFP - Getty Images

Fawaz Gerges, a professor of international relations at the London School of Economics and Political Science, said the Trump administration's decision to strike the militia to send a message to Iran was "monstrously miscalculated."

"It provided Iran with a breathing space in Iraq after months of mass protests criticizing Iranian interference in the country's internal affairs," he said. "It united most political forces in Iraq against the U.S."

Massive anti-government protests have raged across Iraq since October, fueled by anger at widespread corruption and economic mismanagement, as well as Iran's heavy influence over the country's internal affairs. The uprisings prompted the resignation in November of Iraqi Prime Minister Adil Abdul-Mahdi, who is still serving as a caretaker.

Gerges said there was "a real danger that the shadow war between the U.S. and Iran might escalate into a direct confrontation" in 2020. In Iraq, Iran has a strategic advantage over the United States, having co-opted allies and armed militias in the country, he said, adding: "The U.S. has a weaker hand."

Esper said President Donald Trump ordered the deployment of U.S. troops on Tuesday, describing it as an "appropriate and precautionary action taken in response to increased threat levels against U.S. personnel and facilities, such as we witnessed in Baghdad."

Sanam Vakil, a senior research fellow at the London think tank Chatham House, said in an interview that there was no back channel between Tehran and Washington, describing it as "huge problem."

Iran's supreme leader, Ayatollah Ali Khamenei, said Wednesday that if Iran wanted to fight a country, it would do it "straight and clearly."

"The people of this region hate the U.S. See what they have done in Afghanistan, Syria and Iraq," he said.