"Iraq is facing an existential threat but it can be overcome through the formation of a thoroughly inclusive government," Ban told a joint press conference after his meeting with Iraq Prime Minister Nuri al-Maliki.
It must be a government "that can address the concerns of all communities, including security, political, social and economic matters... (and) in which all Iraqis, regardless of background, feel represented", the UN chief said.
He also urged Iraqi political leaders to "fulfill their responsibilities to ensure that the government formation process falls within the constitutional timetable", Xinhua reported.
"It is important for all leaders to fully engage in a meaningful and constructive dialogue with one another, to successfully counter terrorism, strengthen democratic political processes and institutions, respect the rule of law and human rights, and promote inclusive development," Ban said.
Maliki confirmed that the Iraqi authorities would respect the time table of the political process and that the country was on the path of democracy despite facing a violent Islamist insurgency.
"We have assured the secretary-general that the political process is ongoing and we continue to adhere to the constitution and its obligations despite the obstacles that hamper Iraq," Maliki told the news conference.
"We are working, according to the results of the (April 30) elections of the Council of Representatives, and managed to elect the speaker and today to elect the new president of the republic," Maliki said, a few hours before the parliament voted in Fuad Masoum to be declared the new President of Iraq.
"Although we have problems, as a country (in which) democracy and its mechanisms just came around ten years, but we are marching steadily toward democracy," Maliki said.
Despite his latest comments, Maliki's government has been criticised by regional experts and analysts for its reputation of being unfair and not inclusive of the Sunni minority, stoking sectarian tensions in the deeply divided nation.
The UN chief's comments come as Iraq witnesses some its worst violence in years.
Lawmakers are struggling to form a new government that is representative of Iraq's diverse political factions and ethnic groups as recent advances made by the largely Sunni Islamist insurgency threaten to tear the country apart.
Ban arrived in Baghdad earlier Thursday on his sixth visit as UN secretary-general to Iraq. The UN chief last visited Iraq Jan 13.