Baghdad (CNN) -- A bomb exploded on Thursday night in a popular coffee shop in western Baghdad, killing at least 27 people and wounding 51 others, city police officials said.
The bomb was hidden in a plastic bag and then put in a cafe in the Iraqi capital's al-Amriya neighborhood, where it detonated around 10 p.m. (3 p.m. ET), according to police.
They estimated the device contained about two kilograms of highly explosive material.
The explosion ripped through the three-story building, which also includes an ice cream parlor on the first floor and medical offices on the second floor. The coffee shop was on the third floor.
Most of those killed and hurt were young men, though four children were among the dead, police said.
Mostly Sunni Muslims live in the neighborhood, which is surrounded by walls except for one checkpoint staffed by Iraqi soldiers.
The violence follows a spate of attacks preceding the country's provincial elections, set for Saturday.
On Wednesday, three people died and 16 were wounded in four explosions in and around Baghdad, according to police.
There is concern that the security situation could affect the outcome of the vote, especially if Iraqis don't participate because of fears that polling stations may come under attack.
U.N. official Martin Kobler appealed Thursday for security forces to be on "heightened alert" so that citizens can vote "in a safe environment without fear of violence."
In the same statement, Kobler -- the special representative in Iraq for the U.N. secretary-general -- stressed that Iraqi leaders must "collectively endure a transparent and peaceful election, free of intimidation or political interference."
And he urged Iraqis to vote, casting it as their patriotic duty.
"I am calling on all women and men to cast their ballots for a better future for them and their children," Kobler said. "My appeal goes particularly to young Iraqis, because you are the future of this country."
CNN's Mohammed Tawfeeq reported from Baghdad and Greg Botelho wrote this story from Atlanta.