It took three hours to put out the blaze, which broke out overnight inside the maternity unit at the Yarmouk Hospital, in the city's west.
Eight other children and 29 women had to be moved from the unit and transferred to nearby hospitals.
The health ministry said the fire was probably caused by an electrical fault.
Electrical fires are common in Iraq because of shoddy maintenance and poor wiring, and a lack of fire escapes often adds to the danger.
An adviser to the health ministry, Dr Amir al-Mukhtar, said there had been 20 babies inside the maternity unit when the fire erupted around midnight.
The blaze spread very quickly and caused a lot of damage, he added.
A health ministry source told the BBC that 19 of the children and women who survived needed treatment for burns and smoke inhalation.
Relatives of those affected gathered outside the hospital on Wednesday morning. They included Shaimaa Hassan, 36, who lost her two-day-old son.
"I waited for ages to have this baby and when I finally had him, it took only a second to lose him," she told the Associated Press.
Ms Hassan and her husband were visiting the hospital when the fire erupted.
"People started screaming 'fire, fire' and running," she added.
The couple went towards the room where their son was being treated but were stopped by a wall of thick smoke.
"Then someone broke a window and threw me out," Ms Hassan said.
Hussein Omar, 30, said he feared that his week-old twins had died.
Hospital officials had told him to look for them at the other hospitals in Baghdad, he told AP. But he could not find them and was then told to go to the hospital mortuary.
"I only found charred pieces of flesh," Mr Omar said. "I want my baby boy and girl back. The government must give them back to me."
Eshrak Ahmed Jaasar, 41, who was unable to find her four-day-old nephew, blamed the government for the tragedy.
"We pay the hospital employees thousands of Iraqi dinars to allow us in to get our loved ones basic food and milk, which they cannot provide," she said. "It's a corrupt government that doesn't care about its citizens and lets this happen."
An official from the Baghdad health directorate, Jassem Lateef al-Hijami, was quoted by the AFP news agency as saying:
"The hospital is very old and doesn't have fire equipment."
Photos purportedly taken inside the Yarmouk Hospital showed cockroaches crawling out from between broken tiles, bins overflowing with rubbish, dirty toilets, and patients lying on stretchers in a courtyard, the Reuters news agency reports.
Source www.bbc.co.uk/news/world-middle-east-37031708