The U.S.-led coalition withdrew on Sunday from a military base in northern Iraq that nearly launched Washington into an open war with neighboring Iran.

The K1 Air Base is the third site coalition forces have left this month in line with U.S. plans to consolidate its troops in two locations in Iraq.

A rocket attack on the base in late December killed one American contractor and lead to a series of tit-for-tat attacks between the U.S. and Iran-backed Iraqi militia groups. The attacks culminated in the U.S.-directed killing of top Iranian general Qassim Soleimani and senior Iraqi militia leader Abu Mahdi al-Muhandis.

Coalition forces handed over the K1 air base in the northern Iraqi province of Kirkuk to Iraq's military, according to a coalition statement. At least $1.1 million of equipment was transferred to the Iraqis as 300 coalition personnel departed.

K1 has hosted coalition forces since 2017 to launch operations against the Islamic State group in the nearby mountainous areas. Areas south of Kirkuk, and north of neighboring provinces of Diyala, Salahaddin and Nineveh remain hot beds of IS activity.

The stretch of territory is also disputed between the federal Iraqi government and the autonomous Kurdish region, which has created security gaps benefiting IS militants. The coalition's presence had at times been a mediating presence between the two competing authorities.

A senior coalition official earlier this month claimed IS forces weren't as able to exploit the “security gap” between Iraqi and Kurdish forces as the militants did in the past.

“That doesn’t necessarily mean that Daesh is free to operate in the way that they wish," said the official, using the Arabic acronym for the IS group. “They’re still pretty constrained.”

The coalition official was speaking on condition of anonymity in line with regulations.

U.S.-led forces have already withdrawn this month from Qaim, near the border with Syria and Qayara base, in Nineveh earlier. All were in line with plans to pullout from bases across Iraq and consolidate coalition forces in Baghdad and at Ain al-Asad Air Base in the country’s western desert.

The plan has been in the works since late last year, the senior coalition military official said, and accelerated when Iraqi forces proved they were capable of facing the threat from the IS with limited coalition assistance.