An Iraqi police officer, giving the casualty toll on the condition of anonymity because he wasn't authorised to release the information, said 15 people were killed, including seven policemen.
The US military confirmed it was a female suicide bombing but gave a slightly lower death toll of 14 - seven police officers and seven civilians.
The Associated Press news agency put the number of wounded Iraqis at 40.
Police said the bomber targeted a police patrol that was about 200 metres away from the government compound but many civilians were nearby at stalls selling refreshments, tea and cigarettes as well as vendors preparing court documents outside.
One man who was hit by shrapnel in his hand and shoulder said the blast occurred as many people were leaving the compound before the 2pm close of business.
|US sources said the Baquba blast killed seven policemen besides civilians [AFP]
An AFP correspondent on the scene said several police vehicles were set alight by the explosion, and nearby buildings were also damaged by the blast.
Baquba and surrounding areas have seen a series of suicide bombings by women over the past year.
Diyala, a stronghold of al-Qaeda in Iraq, remains one of the most dangerous regions in Iraq despite levels of violence nationwide hitting a four-year low.
Iraqi and US forces have been engaged in a sustained offensive against al-Qaeda in Diyala.
In another attack on Sunday, four people were killed when their car struck a roadside bomb on a road west of the oil hub of Kirkuk in northern Iraq, a police officer said.
Two others were wounded in the blast.
In a similar incident, three people including two women were killed when their car hit a roadside bomb south of Kirkuk, local police said.
Elsewhere on Sunday, Iraqi police said they arrested six men suspected in the killing of the head of Saddam Hussein's tribe.
Sheikh Ali al-Nida, the head of the Albu Nasir tribe, and one of his guards were killed on June 10 when a bomb planted on their car exploded in Tikrit.
Police said three of those arrested were related to al-Nida. Another was his longtime personal driver and trusted family employee, who police said had accepted money to stick a bomb on the undercarriage of the car.
Last year, al-Nida founded an Awakening Council in Saddam's home village of Ouja, partnering with US forces to fight al-Qaeda in Iraq fighters in the area.
The officer said investigators suspected al-Qaida in Iraq was behind al-Nida's killing.
Against the backdrop of Sunday's violence, Al Jazeera aired mobile-phone pictures apparently showing Iraqi troops in Basra arresting and torturing a number of Iraqis.
The bloodied men, shown being carried on the bonnets of Iraqi military vehicles, are believed to be supporters of Muqtada al-Sadr, the Shia leader.
The footage has surfaced as human-rights organisations accuse the Iraqi forces of committing systematic torture and other abuses against people in detention.
The Iraqi government has been accused of failing to investigate many incidents of human-rights abuse and bring those responsible to justice.