U.S. soldiers stand guard during the hand over ceremony of Qayyarah Airfield, Iraqi Security Forces, in the south of Mosul, Iraq early Friday, March 27, 2020. Iraq's military on Thursday said at least two rockets hit inside Baghdad's heavily fortified Green Zone, the seat of Iraq's government and home to the American Embassy, in the first attack following a brief lull in violence from earlier this month. (AP Photo/Ali Abdul Hassan)

BAGHDAD (AP) — The U.S.-led coalition in Iraq withdrew Sunday from a military base in the country's north 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 Gen. Qassem Soleimani and a senior Iraqi militia leader, Abu Mahdi al-Muhandis.

Coalition forces handed over the K1 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.

Until last month, there were some 7,500 coalition troops based in Iraq, including 5,000 U.S. forces.

Withdrawals are planned “in the coming days” from two bases in western Iraq, said Col. Myles Caggins, a coalition spokesman. He said troops have so far been relocated to other bases in the country and some will head home in the coming weeks, but did not specify how many.

He said the two bases are the Nineveh Operations Command in Mosul — Iraq’s second-largest city and which was under the Islamic State group's control from 2014 until 2017 — and the Taqaddum military airport outside the city of Habbaniya, on the Euphrates River.

K1 has hosted coalition forces since 2017 to launch operations against IS in nearby mountainous areas. Areas south of Kirkuk, and north of neighboring provinces of Diyala, Salahuddin and Nineveh remain hotbeds 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 force 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 (gap) doesn’t necessarily mean that Daesh is free to operate in the way that they wish," said the official, using the Arabic acronym for IS. “They’re still pretty constrained.”

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

U.S.-led forces have already withdrawn this month from the Qayara base in Nineveh province followed by the Qaim base near the border with Syria. All the withdrawals were in line with plans to pull out from bases across Iraq and consolidate coalition forces in Baghdad and at the 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 has said, and accelerated when Iraqi forces proved they were capable of facing the IS threat with limited coalition assistance.

Coalition officials said they would still assist Iraqi forces with air support and surveillance, but significantly cut back on training and ground operations, as the limited withdrawal continues.