Iraqi security forces on Tuesday regained full control of the western town of Rutbah, after an attack by IS militants forced government troops to partially withdraw from the town.

Iraqi security forces on Tuesday regained full control of a western town that was attacked by Islamic State (IS) militants two days earlier, officials said.

Seeking to draw attention away from the offensive to retake the city of Mosul, IS struck the town of Rutbah in the country's west and Kirkuk in the north in recent days.

"Our forces completely cleared the town of Rutbah," Staff Major General Ibrahim al-Mahalawi said.

On Monday, Iraqi and tribal forces had to retreat from parts of Rutbah after intense clashes with IS militants.

However, a large number of army reinforcements were sent to the town to reestablish government control.

An AFP journalist who visited the town confirmed that it was fully back in government hands, as did the local official responsible for the area.

The extremists attacked Rutbah on Sunday, briefly seizing the mayor's office before being pinned back by the security forces but still maintaining control of two neighbourhoods.

The extremists executed five Iraqis, including members of the security forces, in the town on Monday, army officers said.

On Friday, dozens of extremist fighters launched a spectacular attack on the Kurdish-controlled city of Kirkuk, killing at least 46 people, mostly members of the security forces.

Iraqi forces are advancing on Mosul, IS’ last major stronghold in the country, from three sides after announcing the start of the operation on October 17.

IS overran swathes of Iraq in 2014 and 2015, but has since lost much of the territory it seized.