A suicide bomber slammed a car packed with explosives into the gate of a prison north of Baghdad on Monday, killing at least 19 people, Iraqi officials said.
Also, a rare explosion inside Baghdad's heavily protected Green Zone killed one person, officials said.
The prison bombing in the town of Taji, about 12 miles (20 kilometers) north of the capital, is the third major attack in about a week in Iraq, and raises questions about the ability of the nation's security forces to protect the country after U.S. troops leave in just over a month.
A senior Iraqi security official warned that even more attacks may be in the offing ahead of the American withdrawal.
The attacker struck the main gate of al-Hout prison at 8:00 a.m. local time, when many employees and guards were on their way to work, said a police officer. Ten policemen were among the dead and the rest were civilians, he added. At least 22 people were wounded.
Two health officials in nearby hospitals confirmed the causality figures.
The officials spoke on condition of anonymity because they were not authorized to brief the media.
Guards and policemen fired into the air to disperse the crowds after the explosion, fearing a second blast, said policeman Hisham Ahmed.
"Our patrol rushed to the explosion site. There was smoke and fire all around the place. I saw bodies of four policemen on the ground and scattered flesh," he said. "Women were among the wounded."
Security forces set up a cordon around the prison to prevent any escape attempt by the inmates, Ahmed said.
No group immediately claimed responsibility for the prison attack, but suicide bombings are a hallmark of al-Qaida in Iraq.
The military spokesman for Baghdad, Qassim al-Moussawi, said that the aim of the latest attacks across the country was to "negatively affect the morale" of the Iraqi security forces. He said he was expecting more attacks by insurgents ahead of the U.S. withdrawal.
"We have information that terrorist groups are planning to intensify their activities, and they are mobilizing all their capabilities to increase attacks for the rest of the year," he said.
In Baghdad, one person was killed and two wounded during an explosion inside the Green Zone, al-Moussawi said.
The vast area in central Baghdad is the most protected area in Iraq and houses the U.S. Embassy and the Iraqi parliament.
Al-Moussawi said he did not know the cause of the blast. Shiite militants often launch mortars and rockets into the Green Zone, usually in an attempt to hit the U.S. Embassy or American military facilities located there.
Another Iraqi security official said one of the wounded was an Iraqi lawmaker who was getting into his car at the time of the blast. The official did not want to be identified because he was not authorized to speak to the media.
Meanwhile, two civilian bystanders were killed and five others wounded by a roadside bomb targeting a police patrol in western Baghdad, police officials said.
Violence has ebbed across Iraq since the height of the fighting, but deadly bombings and shootings still occur almost daily as U.S. troops prepare to leave.
Last Saturday a string of explosions hit a market in Baghdad and an area on the city's western outskirts, killing at least 15 people. Three days earlier, a triple bombing in the southern city of Basra killed 19 people.
Iraqi security officials maintain that they are fully prepared for the American withdrawal, which is required under a 2008 security pact between the U.S. and Iraq. About 15,000 U.S. troops are still in the country, down from a one-time high of about 170,000. All of those troops will be out of the country by the end of December.
But many Iraqis are concerned that insurgents may use the transition period to launch more attacks in a bid to regain their former prominence and destabilize the country.
Associated Press Writer Sameer N. Yacoub contributed to this report.