Baghdad (AFP) - Islamic State fighters retreated from several western Iraqi towns and towards the Syrian border on Sunday as security forces worked their way up the Euphrates Valley, officers said.

The jihadist organisation's leadership ordered its fighters out of Hit, Kubaysa and Rutba, prompting thousands of civilians to take to the road to meet advancing federal forces while others enjoyed their first hours of freedom in months.

"The majority of Daesh (IS) fighters in Hit, Rutba and Kubaysa have fled through the desert to other regions," Yahya Rasool, Iraq's top security spokesman, told AFP.

Hit, around 145 kilometres (90 miles) west of Baghdad, was one of the main towns in Anbar province that was still held by IS.

Kubaysa is a smaller town to the west of Hit while Rutba is a desert outpost on the road to Jordan about 390 kilometres (245 miles) west of the capital.

"There is an operation to hunt them down with Iraqi aircraft," said Rasool, spokesman for the Joint Operations Command coordinating the fight against IS in Iraq.

"Hit is surrounded by Iraqi forces from the south and north," he said. "Thousands of families have fled the area to meet our forces."

Iraqi government forces have yet to enter Hit and no security source would immediately confirm whether any holdout IS fighters remained.

However, residents reached by AFP said no jihadists were visible on Sunday following a pullout that began on Saturday.

One resident said IS's local military leader was killed in an air strike as he tried to escape on Saturday.

"Ahmed Mashaan Abdelwahed al-Batran was killed when an air raid destroyed his boat -- he was trying to cross the river with his family," he said.

"Since yesterday, the Hisba (Islamic police) has vanished from the streets. Before they withdrew, Daesh (IS) fighters booby-trapped houses, roads and government buildings," he added.

- First cigarette -

Another Hit resident said one of the first things the men did after IS pulled out was to light a cigarette.

Story continues

"The young people in Hit are smoking on the street and they also changed back into their normal clothes," he said, also speaking on condition of anonymity.

"There are women in the street without the niqab (full veil) for the first time" since the town fell to IS in October 2014, he said.

Witnesses and officials said IS leaders -- many of them from the city of Mosul or foreigners -- tried to slip out of Hit by blending in with fleeing families after shaving their beards.

"Yesterday there was not one razor blade left in the markets of Hit," the second witness told AFP.

The top regional army commander, 7th division chief Noman al-Zobaie, overflew the city to assess the situation, senior officials said.

Naim al-Kaoud, leader of the local Albu Nimr tribe, said tribal fighters in the area were close to Hit but awaiting government coordination to move in.

"The decision to retake control of Hit has to come from the leadership of the security forces. It is when they go in that the recapture of Hit will be complete," he told AFP.

In Rutba, "Daesh's armed men started pulling out last night and completed their withdrawal this morning," a major general told AFP on Sunday.

He said they all moved towards Al-Qaim, a jihadist bastion on the border with Syria, further north in Anbar province.

After launching a final push against IS in provincial capital Ramadi late last year, Iraq's security forces established full control over the city last month.

They have since been securing areas east of Ramadi, further isolating the jihadist stronghold of Fallujah, which is only 50 kilometres (30 miles) west of Baghdad.

The US-led coalition that has been carrying out air strikes against IS for more than a year and a half has said that the jihadist group was stretched increasingly thin.

Iraqi forces have in recent weeks been trying to flush out jihadists from vast areas around Lake Tharthar, which straddles Anbar and the province of Salaheddin.

In several of its strongholds, IS is reported to have forcibly recruited children for checkpoints duty as it sends adult males into combat.