WASHINGTON — The State Department ordered a partial evacuation of the United States Embassy in Baghdad on Wednesday, responding to what the Trump administration said was a threat linked to Iran, one that has led to an accelerated movement of American ships and bombers into the Persian Gulf.

The department ordered “nonemergency U.S. government employees,” at both the embassy in Baghdad and the consulate in Erbil, to leave the country. The order applies primarily to full-time diplomats posted to Iraq by State Department headquarters in Washington, and an embassy statement said that visa services in Iraq would be suspended as a result. Contractors who provide security, food and other such services will remain in place for now.

Secretary of State Mike Pompeo said last week that the administration had received intelligence related to “Iranian activity” that put American facilities and service personnel at “substantial risk.” Other American officials have said the same piece of intelligence points to potential attacks by Shiite Arab militias tied to Iran against American troops in Iraq or Syria.

The State Department already had been discussing big cuts to the ranks of employees in the Baghdad and Kabul embassies as part of trying to wind down American involvement in wars in Iraq and Afghanistan, American officials said.