But Prime Minister Nuri al-Maliki, standing next to Ban at a joint news conference, insisted that the Anbar unrest was not due to internal problems, and that dialogue with militants was not an option.
The UN chief's visit to Baghdad comes just months ahead of general elections, with the country suffering its worst spate of unrest since 2008 and militants holding an entire city and parts of another on Baghdad's doorstep.
"I would urge the leaders of the country ... To address the root causes of the problems," Ban said..
"They should ensure that there is nobody left behind. There should be political cohesion" and "social cohesion, and political dialogue, inclusive dialogue," he said.
Also Read
"The security situation in Iraq is undoubtedly a source of great concern," said Ban, adding that he is "deeply concerned by this escalation of violence in Anbar governorate."
Events in the province have united Iraqis, he said, and therefore "today, there is nothing called dialogue."
"Dialogue with whom -- with Al-Qaeda? There is no dialogue with Al-Qaeda, and the Iraqi national decision is to end Al-Qaeda," Maliki said, referring to militant group the Islamic State of Iraq and the Levant (ISIL), which has played a major role in nationwide violence.
Ban is on two-day visit to Iraq and is also due to meet parliament speaker Osama al-Nujaifi, lawmakers, Vice-President Khudayr al-Khuzaie and the head of Iraq's election commission.