US troops fired tear gas in response to violent protests at the country's embassy in Iraq, as militiamen set fire to the building for a second day.
Defence Secretary Mark Esper said about 750 troops would be deployed after one of the worst attacks on a US diplomatic mission in years.
Iran-allied militiamen and supporters had camped out at the gates overnight, a day after breaking into the compound and vandalising a reception area.
They began to withdraw on New Year's Day as troops came in, heeding a call from the Popular Mobilisation Forces, an umbrella group that gathers mainly Shia militia. By evening, all had withdrawn from the perimeter of the compound, the Iraqi military said.
A protest camp has been set up in front of a nearby hotel.
Additional forces from the US Army's 82nd Airborne Division are also prepared to deploy in the next several days.
Mr Esper said: "This deployment is an appropriate and precautionary action taken in response to increased threat levels against US personnel and facilities, such as we witnessed in Baghdad today.
"The United States will protect our people and interests anywhere they are found around the world."
Asked about the possibility of war with Iran, US President Donald Trump said: "Do I want to? No. I want to have peace. I like peace.
"And Iran should want to have peace more than anybody. So I don't see (war) happening."
Earlier on Tuesday, protesters, many of them in militia uniforms, had marched outside the embassy compound , shouting slogans against the US, Israel and Mr Trump.
They pelted the entrance with stones and set fire to a reception area after forcing their way into the site.
One protest leader told crowds: "Our sit-in is eternal, until this devil's den is closed off forever, but don't give anyone an excuse to make your protest violent. Don't clash with security."
Gunfire was heard and there were reports of tear gas, with the Reuters news agency saying 12 people involved in the protests were injured.
The State Department has said all American personnel are safe and that there are no plans to evacuate the embassy.
Mr Trump blamed Iran for the protests and called on Iraq to protect the diplomatic mission, tweeting: "Iran is orchestrating an attack on the US Embassy in Iraq.
"They will be held fully responsible. In addition, we expect Iraq to use its forces to protect the Embassy, and so notified!"
:: Listen to Divided States on Apple podcasts , Google Podcasts , Spotify , and Spreaker
Iran has rejected accusations it was behind the violent protests.
The protesters are angry at Washington for the strikes that killed more than two-dozen fighters from an Iran-backed militia over the weekend. Iraq has condemned the airstrikes.
US officials said the move was in response to rocket attacks on a military base in the northern Iraqi city of Kirkuk on Friday, which left a US contractor dead.