The jihadist infiltrators briefly occupied three areas near the city yesterday, 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.
The operation was likely to have been an attempt to divert the security forces from an offensive they launched last week against the jihadists' last two footholds in Iraq, one of them a series of towns further up the Euphrates Valley from Ramadi.
Also Read
A general who asked not to be identified told AFP government forces had killed 20 jihadists.
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.
Last week saw the launch of twin offensives against the jihadists in the Euphrates Valley near the Syrian border and around the northern town of Hawija.
IS 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 jihadists' 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.
IS 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.
Disclaimer: No Business Standard Journalist was involved in creation of this content