Among those killed was a leader of the neighbourhood guards in the area, Faruq al-Obeidi, who headed a local Awakening Council force backed by the US. Six of his bodyguards and eight civilians also died.
The wounded included five women.
Al-Qaeda is said to regularly attack the Awakening groups which are paid by the US military.
Abu Hanifa mosque is one of the most revered Sunni mosques in Baghdad and was the site where Saddam Hussein, the former president, made his last public appearance before being overthrown by a US invasion in April 2003.