BAGHDAD — As the curfew expired on Sunday, one famed Iraqi musician celebrated by playing his cello for bystanders in the street. Elsewhere, dozens of men, too young to remember life before the nighttime restrictions, jumped into their cars and toured the city in a roaring convoy, suddenly freed.

A barber, Abdul Rahim Raji, trimmed a customer’s beard, an hour past his normal closing time. “We feel secure,” he said, as other customers waited. “We feel Baghdad is returning to what it used to be.”

The government’s decision to lift the curfew brought revelers to the streets, dancing and waving flags to mark the end of rules that lasted a dozen years and symbolized the suffering and everyday sacrifices of Iraqis.

But the milestone came on a day of stunning violence in Baghdad, leaving many other Iraqis in no mood to celebrate, and broad sections of the city quiet after midnight, as if clinging to old routines. At least 47 people were killed on Saturday in explosions that tore through busy markets and restaurants, announcing that the violent era was far from past.