Turkey's leader arrived in Tehran unexpectedly to join Brazil in three-way talks on Iran's controversial nuclear programme Monday, amid reports of a last-gasp solution to the international dispute.

As Prime Minister Recep Tayyip Erdogan flew in, Turkey's Anatolia news agency reported late Sunday that Iran had finally agreed to send its uranium to Turkey for enrichment to resolve the row over its nuclear programme.

The deal was struck Sunday after 18 hours of talks in Tehran between the foreign ministers of Brazil, Iran and Turkey, the agency said, citing diplomatic sources.

Brazil's President Luiz Inacio Lula da Silva, in Iran for a summit of non-aligned countries, also held talks on the nuclear issue with Iran's leadership Sunday.

At Iran's invitation, Erdogan arrived at around midnight local time (1930 GMT) Sunday to join him.

And according to Anatolia's report, Erdogan would on Monday join Lula and Iran's President Mahmoud Ahmadinejad to examine the final, detailed version of the agreement worked out by their foreign ministers.

In comments on Iran's Al-Alam television, a spokesman for Iran's foreign ministry welcomed Erdogan's visit for the three-way as a "sign of progress in the negotiations."

It was certainly a turnaround from the Turkish leader's position on Friday.

At that point he said he was unlikely to join Foreign Minister Ahmet Davutoglu on the trip because of Iran's failure to confirm a commitment to the UN-brokered deal for an exchange of nuclear fuel.

But in an 11th-hour change of plan, he said Sunday he was postponing a visit to Azerbaijan to attend the Tehran talks.

At the heart of the international dispute over Iran's nuclear programme is the suspicion in the West that Iran wants the highly enriched uranium it produces to make an atomic bomb -- a charge Tehran vehemently denies.

Iran has so far dismissed a UN proposal to enrich abroad the uranium it says it needs for a nuclear research reactor, proposing instead a one-shot nuclear fuel exchange on its own soil.

But the Western powers have rejected that scenario. In recent days both Russia and the United States made it clear that they considered Lula's visit to Iran as Tehran's last chance.

Iran faces the growing threat of new UN sanctions over its controversial atomic programme.

But comments by Erdogan before he flew out of Turkey, suggested that there might be a breakthrough in sight.

"We have had contacts at the highest level in Iran," he told reporters in Izmir, southwest Turkey, the Anatolia news agency reported.

"We will find an opportunity to launch the exchange process" for Iranian uranium, he added.

"We thought that we should also go there, in case the exchange takes place in Turkey," he added.

Erdogan himself has previously suggested an exchange of nuclear fuel could take place in Turkey as a means of resolving its neighbour's dispute with the West.

Earlier Sunday, a Brazilian official was upbeat about the outcome of Lula's talks.

"The president remains optimistic about the nuclear talks," the delegation member told AFP on condition of anonymity.

"There are still ongoing negotiations and we have to wait until the end of the talks tomorrow (Monday)."

Turkey and Brazil are both currently non-permanent members of the UN Security Council.

Both have so far resisted US-led efforts to push through a fourth package of sanctions over Iran's failure to heed repeated ultimatums to suspend its sensitive uranium enrichment activities.

- AFP