The meeting in Tehran sought to reach a breakthrough in the showdown over Iran's nuclear program, according to Erdogan.

The last-minute trip followed a "signal" from the talks, which are intended to resolve the dispute over Iran's nuclear energy program, Erdogan told reporters before departing. Erdogan indicated the signal involved Iran's agreement to swap its low-enriched uranium for nuclear fuel, CNN Turk reported.

Erdogan said he hoped an agreement in Tehran would stop the U.N. Security Council from its negotiations on tougher sanctions on Iran.

"The Security Council was contemplating a step in the direction of sanctions as of yesterday," Erdogan said. "As a part of our talks, this has been postponed. Now with this step we are going to take, I hope that we will have the opportunity to overcome these problems."

Iran's official Islamic Republic News Agency made no mention of the nuclear issue in reporting earlier that Lula was sitting down with Ahmadinejad. But French President Nicolas Sarkozy and President Dmitry Medvedev of Russia both have said they back Lula's efforts to resolve the long-running, high-stakes stalemate.

"This could be the last chance before the U.N. Security Council makes the already known decisions," Medvedev said, referring to the U.N. decision on imposing sanctions against Iran.

Sarkozy said earlier that he had spoken with Lula by phone to assure him that Paris supports his efforts to resolve the impasse.

The United States and many other countries believe that Iran intends to develop nuclear weapons. Iran says its nuclear program is for peaceful purposes.

On Saturday, Turkish Foreign Minister Ahmet Davutoglu left for Tehran to join the Iran-Brazil talks. Erdogan said Sunday the anticipated signal from Iran was received and he was changing his schedule to travel to Tehran, postponing a planned visit to Azerbaijan.

Erdogan's statement indicated an agreement in which Iran would send most of its low-enriched uranium to be turned into fuel rods suitable for Turkey's nuclear power reactor that makes medical isotopes.

"After our high-level meeting in Tehran, I believe we will have the opportunity to start the process regarding the swap," Erdogan said. "We said that we will go to Tehran if the swap takes place in Turkey, and we received news that the text includes a reference to this. That's why we are going. Otherwise we wouldn't have gone."

Turkey and Brazil have been working on a joint offer based on the nuclear swap deal offered previously to Tehran. Both countries are temporary members of the U.N. Security Council and have been working toward a diplomatic solution that does not involve sanctions.

Lula also met separately with Iranian Supreme Leader Ali Khamenei on his trip, according to Iranian media reports. State-run Press TV reported Khameini emphasized to Lula the need for relations between independent states such as Brazil and Iran in order to reduce the influence of superpowers such as the United States.

"The only way to change the oppressive relations in the world today is through the formation of closer ties between independent states," Khameini said, according to Press TV. "Superpowers have defined vertical relations in the world which places a superpower at the top. These relations must be changed and their change is possible."