US companies were Thursday evacuating hundreds of Americans working with the Iraqi government from a major air base, US officials said, as Islamic militants swept towards Baghdad.

A US defense official confirmed that "a few hundred" American contractors from Balad air base, 80 kilometers (50 miles) north of the capital, were being moved to Baghdad for security reasons.

"We can confirm that US citizens under contract to the government of Iraq in support of the US Foreign Military Sales (FMS) program in Iraq are being temporarily relocated by their companies due to security concerns in the area," State Department spokeswoman Jen Psaki said.

Militants are closing fast on the capital Baghdad after sweeping up a huge swath of predominantly Sunni Arab territory in northern and north-central Iraq since launching their offensive in the second city of Mosul late on Monday.

Psaki stressed however that the US embassy in Baghdad was still operating, saying "the status of the staffing at the US embassy and consulates has not changed."

The evacuation of Balad was being handled by the companies and did not involve the US government, the defense official said.

"It’s their people. It’s their planes," the official said, asking to remain anonymous.

The contractors are hired out by the Iraqi government and working on programs related to F-16 fighter jets. They are not on the US government’s payroll.

Balad air base was once one of the world's busiest airports and housed some 36,000 American personnel before it was handed over to Iraqi control in November 2011.

The 332nd Air Expeditionary Wing was the last unit to leave JBB, which occupied 25 square kilometers (nine square miles) and had a 20-kilometer security perimeter.