(AFP) -- The [terrorist] infiltrators briefly occupied three areas near the city, which is the capital of mainly Sunni Arab Anbar province, long a bastion of insurgency, the sources said.
But after several hours of heavy fighting in which there were deaths on both sides, all three areas were retaken.
"The security forces and the tribes retook control of the Al-Tash, Majr and Kilometre Seven districts," provincial police chief Major General Hadi Razij Kassar told reporters.
"All the Daesh members were killed," he added, using an Arabic acronym for Isis.
The operation was likely to have been an attempt to divert the security forces from an offensive they launched last week against the [terrorists'] last two footholds in Iraq, one of them a series of towns further up the Euphrates Valley from Ramadi.
A general who asked not to be identified told AFP government forces had killed 20 [terrorists].
A military source in Ramadi hospital said two security personnel were killed and 18 civilians wounded.
"A curfew has been imposed on the city of Ramadi and its surroundings to prevent any security breaches," the general said.
Troops and paramilitaries retook full control of Ramadi from Isis in February 2016 but are still battling to clear the [terrorists] from elsewhere in Anbar province.
Last week saw the launch of twin offensives against the [terrorists] in the Euphrates Valley near the Syrian border and around the northern town of Hawija.
Isis is now under attack in all of its remaining bastions in both the Iraqi and the Syrian arms of the so-called caliphate it declared in 2014.
Since the [terrorists'] defeat in Iraq's second city Mosul in July after a nine-month offensive, the territory they still hold has dwindled fast, with stronghold after stronghold coming under assault on both sides of the border.
Their onetime Syrian bastion Raqa, long a byword for gruesome atrocities, including public executions, is now on the verge of falling to US-backed fighters.
Isis is also under attack by Russian-backed Syrian government forces around the eastern city of Deir Ezzor and in the central provinces of Hama and Homs.
In Iraq, troops and paramilitaries have retaken the town of Sharqat in their drive on Hawija.
They have also recaptured a string of villages around the town of Anna in their push up the Euphrates Valley towards the Syrian border.
(Photo: Troops prepare to enter the town of Sharqat on September 21, 2017, as they close in one of the Isis group's last two enclaves in Iraq. AFP)