President Joe Biden says US forces will end their combat mission in Iraq by the end of this year, but will continue to train and advise the Iraqi military.
The announcement came after Mr Biden held talks with Iraqi Prime Minister Mustafa al-Kadhimi at the White House.
There are currently 2,500 US troops in Iraq helping local forces counter what remains of the Islamic State group.
Numbers of US troops are likely to stay the same but the move is being seen as an attempt to help the Iraqi PM.
The US presence in Iraq has become a major issue since top Iranian general Qasem Soleimani and the leader of an Iran-backed Shia Muslim militia were killed in a US drone strike in the capital Baghdad last year.
Political parties aligned to Iran have demanded the withdrawal of all forces from the US-led global coalition against IS, despite the continuing threat posed by the Sunni jihadist group.
Shia militias have meanwhile been accused by the US of carrying out hundreds of rocket, mortar and drone attacks on Iraqi military bases that host coalition forces in an apparent attempt to pressure them to leave.
For the US president, the announcement marks the end of another war that began under former President George W Bush. This year he said US troops would leave Afghanistan.
Speaking at the White House, Mr Biden told his Iraqi counterpart "our counter-terrorism co-operation will continue even as we shift to this new phase."
Mr Kadhimi responded: "Today our relationship is stronger than ever. Our co-operation is for the economy, the environment, health, education, culture and more." He has insisted no foreign combat troops are needed in Iraq.
US-led forces invaded Iraq in 2003 to overthrow President Saddam Hussein and eliminate weapons of mass destruction that turned out not to exist.
Then President George W Bush promised a "free and peaceful Iraq", but it was engulfed by a bloody sectarian insurgency.
US combat troops eventually withdrew in 2011. However, they returned at the request of the Iraqi government three years later, when IS militants overran large parts of the country.
Following the military defeat of IS in Iraq at the end of 2017, US forces remained to help prevent a resurgence of the group.
"Our role in Iraq will be dealing with being available to continue to train, to assist, to help and deal with ISIS as it arrives," Mr Biden added at the meeting.
"But we're not going to be, by the end of the year, in a combat mission."
The BBC's Frank Gardner says the risk of IS once again sweeping aside the Iraqi army is reduced for several reasons.
The political situation in Iraq is more acceptable to the country's competing ethnic groups than it was in 2014.
The US-led coalition has spent a lot of time and effort in training up Iraq's counter-insurgency forces, and the IS leadership currently appears to be more focused on exploiting the ungoverned spaces in Africa and Afghanistan, our correspondent adds.
Ever since Iran's Islamic Revolution in 1979 it has been trying to evict US forces from its neighbourhood and become the premier power in the region.
It has had little success in the Arab Gulf states where mistrust of Tehran runs deep and where the US military has facilities in all six countries.
But the US-led toppling of the Saddam Hussein regime in Iraq removed the most effective obstacle to Iranian expansion, and Tehran has not passed up on the opportunity since then. It has successfully inserted its Shia militias into the fabric of Iraq's security establishment, and its allies have a powerful voice in parliament.
Syria's civil war has opened the door for a major Iranian military presence there, while next door in Lebanon Iran's ally Hezbollah has become the most potent force in the country.
Iran is playing the long game. Its leaders hope that if it keeps up the pressure, both overt and covert, it will eventually make the Middle East a region not worth America's effort to stay engaged in, militarily.
Hence the frequent rocket attacks on US bases and Iran's support for civil protest calling for US troops to leave.
An agreement that sees the end of US combat operations in Iraq will be seen by many in Tehran as a step in the right direction.