A series of car-bomb attacks have hit two cities in Iraq, leaving dozens of people dead.

In the capital Baghdad, at least 27 people were killed on Friday in multiple blasts.

The deadliest attack was inside a car dealership in the mainly Shia Habibya neighbourhood in the east of the city. No one has claimed responsibility.

At least eight Iraqi soldiers were also killed in Baghdad due to shelling of the town by ISIL.

In Friday's other attack, a car bomb struck next to the US consulate in Erbil, the capital of Iraq's Kurdish region.

Security sources said the blast in the Ankawa district killed at least three people and injured five others.

Government officials in Erbil said the suicide bomber detonated his explosives in a car parked near the consulate building when security guards became aware of his presence.

US officials said no consulate staff were harmed in the attack, which has been condemned by the US administration.

Islamic State of Iraq and the Levant (ISIL) claimed responsibility for the Erbil bombing, according to the SITE Intelligence Group.

SITE cited an ISIL account on Twitter claiming that fighters from its Kirkuk division "were able to detonate a car bomb on the building of the American consulate in the city, which led to killing and wounding many of them".

Al Jazeera's Kim Vinnell, reporting from Erbil, said the blast came just days after US and Kurdish officials applauded the advances they had made against ISIL in Iraq.

"It's too early to say whether gains have been made," she said after Friday's attack.

The US condemned the attack on its consulate and reassured the public that no US citizens were injured or killed after the attack.

US officials also said that they found the ISIL claim of responsibility credible. "We have no reason to doubt their claim of responsibility," a US counterterrorism official told Reuters news agency.

Such attacks are relatively rare in Kurdistan, which has managed to insulate itself from the worst of the violence afflicting the rest of Iraq.

The last major attack in Erbil, also claimed by ISIL, was in November 2014, when a suicide car bomber blew himself up outside the governor's office, killing five.

Elsewhere in the Kurdistan region, Iraqi forces - backed up by Shia fighters and the Kurdish peshmerga and aided by US air strikes - have advanced on several villages south of Kirkuk, including Duquq and Bashir, which has long been under ISIL control.