It was the worst attack in Baghdad since 32 people were killed in twin car bombings in the predominantly Shia district of Bayaa in the city's southwest on September 26.
The US defence secretary was in the capital to assess whether a reported downturn in fighting in Iraq could be sustained.
Gates flew into the northern city of Mosul earlier on Wednesday in an unannounced visit to the country, and proceeded to Baghdad after meeting US commanders.
One person was killed by a car bomb near a police station in Mosul hours before Gates touched down. Car bombs in Baquba and Kirkuk, another two cities north of Baghdad, killed at least seven more.
The US military also announced the deaths of three soldiers, killed in a "complex attack" a day earlier involving a roadside bomb and small-arms fire north of Baghdad.
Despite the ongoing fighting, Gates said he believed "a secure, stable and democratic Iraq is within reach", although much remains to be done.
"We need to be patient," the Pentagon chief told reporters, standing alongside Abdul-Qader al-Obeidi, Iraq's defence minister.
"We also need to be absolutely resolved in our desire to see the nascent signs of hope across Iraq expand and flourish so that all Iraqis can enjoy peace and prosperity."
With attacks reportedly at their lowest levels in nearly two years, attention has focused on whether the Shia-led government can reconcile with disaffected Sunni Arabs, especially as the US begins limited troop withdrawals.
Gates urged the Iraqi government to integrate mainly-Sunni Arab neighbourhood patrol units with its army and police.
Washington credits the 60,000-strong neighbourhood patrol forces with helping to reduce violence.
"Iraqis who have chosen to fight al-Qaeda need to be integrated into Iraq's security forces or provided other job opportunities," he said.
Earlier on Wednesday the government took a step in that direction, announcing that it would put 45,000 of the patrol members on its payroll by the middle of 2008.
That means tens of thousands of armed Sunni Arabs, many believed to have fought against the government before this year, will soon be working for it.
Despite the reported security gains, Colonel Raymond Thomas, an assistant commander of the US division responsible for the north, said it was asking for more troops for Diyala province, of which Baquba is the capital.
The US reports that attacks across Iraq have fallen 55 per cent since a build-up of American troops became fully deployed in mid-June.
US military commanders say they are confident they can maintain gains in security despite the planned withdrawal of more than 20,000 soldiers over the next six to eight months.
There are around 160,000 American troops in Iraq.