BAGHDAD — Islamic State militants claimed full control of the western Iraqi city of Ramadi on Sunday in the biggest defeat for the Baghdad government since last summer.

In a statement, the group said it had seized tanks and killed “dozens of apostates,” its description for members of the Iraqi security forces.

Ramadi is the capital of Iraq’s western Anbar province, which is dominated by Sunni Muslims. Prime Minister Haider al-Abadi signed off on the deployment of Shiite militias to attempt to seize back the area, a move he had previously resisted for fear of provoking a sectarian backlash.

Earlier, security sources said government forces evacuated a key military base after it came under attack by the insurgents, who had already taken one of the last districts still holding out.

It was the biggest victory for Islamic State in Iraq since security forces and Shi’ite paramilitary groups began pushing them back last year, aided by airstrikes from a U.S.-led coalition.

The government had vowed to liberate Anbar after routing the militants from the city of Tikrit last month. But the security forces, which partly disintegrated under an IS onslaught last June, have struggled to gain traction in the vast desert province.

An officer who withdrew from the besieged army base said the militants were urging them via loudspeaker to discard their weapons, promising to show mercy in return.

“Most of the troops withdrew from the operations command headquarters and Daesh fighters managed to break in from the southern gate,” the officer said. Daesh is an Arabic name for Islamic State.

“We are retreating to the west to reach a safe area.”

‘Total collapse’

Earlier Sunday, Anbar provincial council member Athal Fahdawi described the situation in Ramadi as “total collapse.”

It was one of only a few towns and cities to have remained under government control in the vast desert terrain, which borders Saudi Arabia, Syria and Jordan.

Islamic State, which emerged as an offshoot of al-Qaida, controls large parts of Iraq and Syria in a self-proclaimed caliphate where it has massacred members of religious minorities and slaughtered Western and Arab hostages.

The United States and its allies have been pounding the militants for months with airstrikes in both countries. Washington said Saturday its special forces had killed a senior IS figure in a raid into Syria.