The dead were heading to Baquoba to visit relatives. They included two children, three women and a man, police in Diyala province said. Another woman and her small child were injured.
The bombings in Baghdad occurred as Shiite worshippers celebrated the holiday of Eid al-Fitr, which marks the end of the fasting month of Ramadan.
No group claimed responsibility, but attacks on Shiite civilians are widely associated with Sunni extremists like al-Qaida in Iraq hoping to re-ignite the sectarian conflict that pushed the nation to the brink of civil war two years ago.
In the deadliest attack, a suicide car bomber in a white Mercedes sedan detonated his explosives about 20 yards from a mosque in Zafaraniyah in southeastern Baghdad. He set off the bomb when Iraqi soldiers tried to stop him from approaching the building, police said. That attack killed 14 people, including three Iraqi soldiers, and injured 28, police said.
In the other attack, a suicide bomber who appeared to be in his late teens detonated his explosive belt as worshippers were leaving the Rasoul mosque in the capital's eastern New Baghdad district.
Ten people died and 24 were injured, police and officials at the al-Kindi and Ibn al-Nasif hospitals said.
The attacker approached the mosque and set off the explosion as a suspicious guard tried to keep him from entering. The guard was among those killed, police said.
The police officials all spoke on condition of anonymity because they were not authorized to speak to the press.
A witness to the Zafaraniyah attack said he saw a white car speed toward the mosque and then heard a huge explosion that sparked a fire and heavy smoke. Ammar Hashim, 25, who runs a car parts shop nearby, rushed to the site and saw "a damaged and burned Humvee with dead and burned bodies and many injured people crying out in pain."
"Pools of blood and the smell of burned flesh was everywhere and I saw a man of about 70 bleeding and lying on the ground from injuries," said Hashim, whose brother was also injured by broken glass in his shop.
Hashim said civilian cars began to rush people to a nearby hospital before ambulances arrived.
Footage from Associated Press Television News showed slippers and shoes scattered on the bloodstained ground. The blasts blew out windows nearby and slightly damaged some shops.
The faithful at both mosques are followers of Grand Ayatollah Ali al-Sistani, the country's top Shiite cleric. Sunnis and other Shiite groups celebrated the Eid al-Fitr holiday earlier in the week.
Separately Thursday, a bomb in western Baghdad wounded four American soldiers, U.S. military spokesman Lt. Col. Steven Stover said. He gave no other details, but Baghdad police said the attacker was a suicide bomber in a car who detonated his explosives on a U.S. convoy.
Two Iraqi civilians were also wounded, a police official said on condition of anonymity because he was not authorized to speak to the press.
Associated Press writers Hamid Ahmed and Saad Abdul-Kadir contributed to this report.