BAGHDAD // The outgoing Iranian president, Mahmoud Ahmadinejad, paid a final official visit to Iraq yesterday, seeking to emphasise the growing relations between the Shiite-led neighbours just weeks before he steps down from his job at his term's closing.

The Iranian leader is meeting top Iraqi officials and visiting Shiite holy sites during his two-day visit to Iraq, which is grappling with its worst outbreak of violence in half a decade. Iraq is home to some of Shia Islam's most sacred shrines and is a major destination for the sect's pilgrims.

Mr Ahmadinejad is just weeks away from handing over power to the president-elect, Hassan Rouhani, who is expected to be sworn in early next month.

That leaves little chance that Mr Ahmadinejad's visit will lead to major shifts in foreign relations between the countries or their stance towards the Syrian civil war raging across Iraq's western border.

Mr Ahmadinejad emphasised Tehran's determination to strengthen ties further with Baghdad while linking his own country's success with that of Iraq.

"The prosperity, progress and security of Iraq are also Iran's prosperity, progress and security," he said.

Mr Ahmadinejad previously flew to Iraq in 2008, the first trip by an Iranian president since Iran's 1979 Islamic Revolution and the two countries' war in the 1980s. He used that earlier visit to emphasise a new chapter in "brotherly" relations between the one-time foes and take swipes at the United States over the legacy of its 2003 military invasion.

It was a theme he sounded again Thursday.

"We are determined to make use of all available opportunities to develop brotherly relations," Mr Ahmadinejad said.