Updated

Iraqi special forces maintained control of the provincial capital, Ramadi, in Iraq's western Anbar province Friday, after Islamic State militants continued to pound the western city with bombings, causing fearful residents to flee their homes.

Anbar provincial council member Athal al-Fahdawi said Thursday the city was "in great danger," the BBC reported. Nine people were killed by militants in the village of Albu Ghanim— four of the victims were police officers, the Kurdish website Rudaw said- and thousands of people fled Ramadi and surrounding areas in recent days.

Sabah al-Karhout, head of Anbar's provincial council, said there were no major attacks on the city Friday but that the militants still maintained control of three villages to the east of Ramadi, which they captured Wednesday.

Suicide bombers attacked government buildings and checkpoints in Ramadi earlier in the week and Friday a series of bombings ripped through Baghdad, mainly targeting public places and killing at least 40 people, Iraqi officials said.

A car bomb went off at a car dealership in the Shiite neighborhood of Habibya in eastern Baghdad, killing 15 people and wounding 26, police said. Several cars were burned in the attack. A half-hour earlier, a car bomb detonated near an outdoor market, killing 13 people and wounding 24.

No group immediately claimed responsibility for the attacks but violence has escalated both in Baghdad and elsewhere in Iraq in the wake of Islamic State group's capture of large parts of the country last year. The Islamic State has taken credit for similar attacks in the past, especially those targeting Shiites, as well as Iraqi security forces and government buildings.

The attacks come as Iraqi government forces and allied Shiite and Sunni fighters-- backed by airstrikes from the U.S.-led international coalition-- are battling ISIS militants to retake key cities and territory in northern and western Iraq.

Sabah Nuaman, a special forces commander in Anbar, said the situation had improved early Friday after airstrikes hit key militant targets on the city's fringes.

Also Friday, Iraqi security forces gained full control over a contested area south of the Beiji refinery, as part of their push to secure the rest of Salahuddin province.

General Ayad al-Lahabi, a commander with the Salahuddin Command Center, said the military, backed by U.S.-led coalition airstrikes and Shiite and Sunni militias dubbed the Popular Mobilization Forces, gained control of the towns of al-Malha and al-Mazraah, located 1.9 miles south of the Beiji oil refinery, killing at least 160 militants with the Islamic State group.

Al-Lahabi said security forces are trying to secure two corridors around the refinery itself after the Sunni militants launched a large-scale attack on the complex earlier this week, hitting the refinery walls with explosive-laced Humvees.

Extremists from the Islamic State group seized much of Salahuddin province last summer during their advance across northern and western Iraq.

The battle for Tikrit was seen as a key step toward eventually driving the militants out of Mosul, Iraq's second-largest city and the capital of Nineveh province. In November, Iraqi security forces said they had recaptured the town of Beiji from the militant group. The refinery had never been captured by the militants but has been subjected to frequent attacks by the group.

The Associated Press contributed to this report.