Iran's President Mahmoud Ahmadinejad has told Iraq he supports a crackdown on Kurdish guerrillas in northern Iraq but wants a peaceful solution to the crisis, Iraq's government said.

A statement from Iraqi Prime Minister Nuri al-Maliki's office released overnight said Ahmadinejad had phoned Maliki to discuss the issue. Turkey is massing troops on the border and threatening to invade if Iraq cannot stop cross-border attacks.

"The two men have agreed the necessity of confronting the terrorist activities of the PKK, which damage the interests of Iraq, Turkey and Iran," the statement said.

"They agreed that military action is not the sole option in dealing with the crisis, which should be resolved by peaceful means."

Ahmadinejad also phoned Iraqi President Jalal Talabani overnight, Talabani's office said.

"He expressed his solidarity with Iraqi people's ambitions to live peacefully away from the woe of war and infighting, and expressed his readiness to make efforts to end the current tension on Iraqi-Turkish border peacefully," said a statement released from Talabani's office on Sunday.

"Talabani expressed his hopes that President Ahmadinejad could make efforts with Turkish Foreign Minister Ali Babacan, who is in Iran now, to help the language of dialogue and understanding prevail over the language of threats and following the military path."

The PKK is fighting for a Kurdish homeland in southeastern Turkey. Iran also has a Kurdish minority and has faced cross-border attacks by rebels. Like Turkey, Iran has at times shelled targets inside Iraq in response to the raids.

Iraq says it cannot confront the rebels in their remote mountain hideouts but has promised to take steps to stop them launching attacks on Turkey. Ankara has so far rejected the proposals as inadequate.