BAGHDAD – Baghdad’s decade-old nightly curfew ended after midnight Sunday, hours after bombs exploded in and around the Iraqi capital, killing at least 40 people in a stark warning of the dangers still ahead in this country under attack by the Islamic State group.

The deadliest of Saturday’s bombings happened in the capital’s New Baghdad neighborhood, where a suicide bomber detonated his explosives in a street filled with hardware stores and a restaurant, killing 22 people, police said.

“The restaurant was full of young people, children and women when the suicide bomber blew himself up,” witness Mohamed Saeed said. “Many got killed.”

The Islamic State group later claimed responsibility for the attack, saying their bomber targeted Shiites, according to the SITE Intelligence Group, a U.S.-based terrorism monitor. The Sunni extremist militants now hold a third of both Iraq and neighboring Syria in their self-declared caliphate.

A second attack happened in central Baghdad’s popular Shorja market, where two bombs some 25 meters (yards) apart exploded, killing at least 11 people, police said. Another bombing at the Abu Cheer outdoor market in southwestern Baghdad killed at least four people, police said.

In Tarmiya, a Sunni town 30 miles (50 kilometers) north of Baghdad, a bomb blast killed at least three soldiers in a passing convoy, authorities said.

Hospital officials confirmed the casualty figures. All officials spoke on condition of anonymity as they weren’t authorized to brief journalists. No group claimed the other attacks.

Despite the bombings, the government went ahead with its plans to lift the nightly midnight-to-5 a.m. curfew on Sunday. The curfew largely had been in place since 2004, in response to the growing sectarian violence that engulfed Iraq after the U.S.-led invasion a year earlier.

Square in central Baghdad amid major security presence. Men, women and even children awake well past midnight played music and waved Iraqi flags.

A crowd of men, women and even children played music and waved Iraqi flags early Sunday as they gathered amid a heavy security presence in central Baghdad’s Tahrir Square to celebrate the curfew’s end. Elsewhere, small groups of young men rode around the capital early Sunday on motorcycles and in cars, cheering and waving Iraqi flags.

There was no immediate comment Saturday from Prime Minister Haider al-Abadi, who on Thursday announced plans to end the curfew by decree. He also ordered that streets, long blocked off for security reasons, reopen for traffic and pedestrians.

Iraqi officials repeatedly have assured residents that the capital is secure, despite Sunni militant groups occasionally attacking Baghdad’s Shiite-majority neighborhoods.

Associated Press writer Murtada Faraj contributed to this report.