The attack took place last night in the Mansour district of the capital, the officials said.They named the victim as General Imad Hasham of the army's sixth division.
In another attack last evening, gunmen also with silenced weapons shot and wounded police Lieutenant Colonel Majid Hamid as he was driving through the Amiriya area of Baghdad, the officials said.
Prime Minister Nuri al-Maliki named security as one of his three top priorities after parliament on Tuesday approved his nomination for a second term of office and gave its stamp of approval to his national unity government.
While violence has dropped dramatically across Iraq since its peak in 2006 and 2007, attacks remain common, especially in the capital and the main northern city of Mosul.
The number of people killed in violence in Iraq last month was the lowest in a year for the second month running, with 171 people -- 105 civilians, 23 soldiers and 43 policemen -- dying in attacks.