The assault began when a series of mortar shells slammed into the Nahrawan power station, police Lieutenant Bilal Ali Majed said. Half an hour later, dozens of armed men arrived in pickups and set fire to the station.
Security guards returned fire, and the Iraqi police and army sent in reinforcements, he said.
At least nine people were killed and three wounded in the gun battle, police Lieutenant Mohammed Kheyoun said. He identified the victims as guards and technicians at the station but did not know whether any attackers were killed or wounded.
In the adjacent Maamil suburb, armed men shot to death 10 Shia southerners employed at a brick factory as they slept in their shacks, said Major Falah al-Mohammedawi, an Interior Ministry official. Police thought the armed men may have been part of the group that attacked the power station, he said.
South of Baghdad, a mortar shell slammed into a market on Friday in Mahmudiya, killing one person and wounding another, police Captain Rasheed al-Samaraie said.
The government imposed the vehicle ban Friday in an effort to avert more attacks on the day Muslims congregate in large numbers for the most important prayer service of the week.
Security forces sealed off Baghdad, preventing most vehicles from entering or leaving the city of seven million, said Captain Adil Mohan of the traffic police.