Shortly before the explosion, al-Maliki had said that Ban's visit was a sign that Iraq was on the road to stability.
"We consider it [the visit] a positive message to world in which you [Ban] confirm that Baghdad has returned to playing host to important world figures because it has made huge strides on the road toward stability," the prime minister said.'Secure future'
Ban had said: "I'm confident that we'll be able to see, in the near future, a more prosperous and secure ... and a healthier future of the Iraqi people and government."
He told the news conference he had a "very good meeting" with al-Maliki and pledged UN support for his government before leaving shortly after the blast.
Last week, Ban appealed for support for the International Compact, a plan outlining targets for Iraq over the next five years, including annual economic goals.
It also includes a list of legislation the government hopes to pass by the end of this year. He described the compact, which was discussed by more than 80 countries, as a "tool for unlocking Iraq's own potential".
The United Nations has been operating at greatly reduced levels in Iraq since international staff were withdrawn in October 2003 after an attack on their headquarters.
Sergio Vieira de Mello, the UN envoy to Iraq, was among 22 people killed in the truck bombing in Baghdad in August 2003.
The visit also came against a backdrop of more violence in the country.
Three US soldiers were reported killed and rival Shia fighters clashed in Basra, Iraq's second city.