U.S. forces are completing their withdrawal from the last military bases they hold in Iraq, with a Wednesday deadline set under a 2024 agreement between Washington and Baghdad, Reuters reported Tuesday.

The exit formally ends the U.S.-led coalition's military mission in Iraq, which began in 2014 after the Islamic State group overran large parts of the country and neighboring Syria. It also closes a longer chapter that started with the 2003 invasion. Roughly 4,500 Americans died over more than two decades of U.S. military involvement in Iraq, according to Reuters.

The timeline was negotiated under former President Joe Biden. The Trump administration has carried it out even as the United States fights a war with Iran, a conflict that turned the remaining U.S. positions in Iraq's Kurdish north into regular targets. Those bases have come under repeated attack since the U.S. and Israel struck Iran on Feb. 28, Al Jazeera reported.

Tehran's allies moved quickly to frame the departure as their win. Abu Mojtaba al-Yasiri, a commander in the Islamic Resistance in Iraq, an umbrella group of militias that has launched many attacks on U.S. bases, called the withdrawal a historic victory for the armed groups that opposed the American presence. A senior member of the Iranian parliament's national security commission also welcomed the move.

At the height of the counterinsurgency campaign in 2007, more than 170,000 U.S. troops were in Iraq, Al Jazeera reported. Combat forces left in December 2011, then returned less than three years later at Baghdad's request as the Islamic State seized territory.

A U.S. official told The Associated Press in August that Iraqi security forces, including Kurdish Peshmerga units, would lead the fight against militants from here. The official declined to say how many troops remained or where they would be sent.

The State Department still warns Americans against travel to Iraq, citing terrorism, kidnapping and armed conflict. It says both the Islamic State and Iran-aligned militias continue to threaten U.S. citizens and interests in the country.