"We thought that we should also go there, in case the exchange takes place in Turkey."
'Something going on'
Analysts say Erdogan's sudden about-face, over the weekend he had cancelled plans to visit Iran, suggested that the three parties might be close to announcing some kind of agreement.
"It shows that there is really something going on," Mahjoob Zweiri, an Iran expert at Qatar University, told Al Jazeera.
"I think Iran has an interest in keeping Turkey on its side, in keeping Brazil on its side, and it has an interest to add more friends than enemies."
Lula's visit, which has included a meeting with Ayatollah Ali Khamenei, Iran's supreme leader, as well as Ahmadinejad, was portrayed by the US and Russia as Iran's "last chance" to accept a deal and avoid a fourth round of UN sanctions.
But in a brief media appearance after their talks, neither Ahmadinejad nor Lula mentioned the nuclear programme, instead focusing on bilateral trade.
Before departing for Tehran, Lula had said that he was "optimistic" about the visit, and that he hoped to persuade Ahmadinejad to reach an agreement with the West over its nuclear work.
"I must now use everything I have learned over my long political career to convince my friend Ahmadinejad to come to an agreement with the international community," he said.
The US and Russia have already said the chances of success are weak.
But before the talks, Tehran signalled a willingness to listen to any proposals.
"We have received many proposals and we are considering them," Ali Akbar Salehi, Iran's atomic chief, was quoted as saying on Saturday in local media.
"There is a willingness on both sides to resolve the problem and things are moving positively."
Iran has previously been reluctant to allow its stockpile of uranium to leave the country before receiving the nuclear fuel, saying that the exchange must take place simultaneously inside the country.
Last week, however, Mohsen Shaterzadeh, Iran's ambassador to Brazil, said that an exchange in another country might be acceptable.
Brazil and Turkey, both non-permanent members of the UN Security Council, have so far failed to support US-led efforts to push through new sanctions against Iran over its failure to accept repeated ultimatums to stop uranium enrichment activity.
The US and its allies say that Iran wants highly enriched uranium to make an atomic weapon, but Tehran says its programme is simply designed to meet its civilian energy needs.
Lula has in the past defended Iran's nuclear activities, saying Tehran has the right to atomic energy, and has repeatedly said sanctions would be counter-productive and ineffective.