US President Donald Trump says he is open to meeting Iran's President Hassan Rouhani under the right circumstances.
It comes after Iran's foreign minister made a brief and unannounced visit to the G7 summit in France on Sunday.
Relations between Iran and the US have deteriorated since Washington withdrew last year from a 2015 deal to limit Iran's nuclear activities.
However, on Monday, Mr Trump said he had "good feelings" about the prospect of a new nuclear deal with Iran.
"Iran is not the same country it was two and a half years ago when I came into office," he told reporters at a joint G7 press conference with French leader Emmanuel Macron.
"I really believe that Iran can be a great nation... but they can't have nuclear weapons," he said, adding that they had to be "good players" before he would agree to a meeting.
Earlier on Monday, Mr Rouhani said he was ready to meet anyone if he felt it would benefit Iran.
"If I am sure that attending a session or having a meeting with someone will help develop my country and resolve the people's problems, I will not hesitate to do so," he said.
Mr Trump's remarks came at the close of the G7 summit - where leaders from Canada, France, Germany, Italy, Japan, the UK and the US - met in Biarritz.
Other issues they discussed included world trade, fires in the Amazon, and developments in Ukraine, Libya and Hong Kong.
How did we get here?
Tensions with Iran have been heightened since the US unilaterally withdrew from the 2015 nuclear deal, and re-imposed sanctions.
Other parties to the agreement - the UK, France, Germany, Russia and China - have sought to salvage the nuclear deal.
On Sunday, Iranian Foreign Minister Mohammad Javad Zarif said he had had "constructive" talks with his French counterpart, and Mr Macron, on the sidelines of the G7 talks in Biarritz.
Mr Macron, who has taken an active role to try to save the accord, said he had informed Mr Trump of his plan to invite Mr Zarif, after discussions with Iranian officials on possible solutions.
He said he believed the "conditions for a meeting" between Mr Trump and Mr Rouhani "in the next few weeks" had been established.
"Nothing is set yet and things are still fragile, but technical discussions have started with some real progress," he said, adding that he had told Mr Rouhani that "if he accepts a meeting with President Trump, I am convinced an agreement can be found".
What would a new deal actually look like?
The 2015 agreement involved Iran limiting its nuclear activities for between 10 and 15 years, in return for sanctions relief.
The deal restricted Iran's enrichment of uranium and required it to allow international inspections. The accord also stipulated that Iran should redesign a heavy-water reactor being built so that it could not produce any weapons-grade plutonium.
The US withdrew from the deal in May 2018, and issued a list of 12 "requirements" for a new nuclear deal and the lifting of US sanctions. These included Iran curbing its ballistic missile programme, and ending its involvement in regional conflicts.
Iran has described the requirements as unacceptable.
At Monday's press conference, Mr Trump said that for any new deal, he was "looking for no nuclear weapons, no ballistic missiles and a longer period of time".
It is not clear whether Iran would accept any new conditions - Iran's state-run Press TV, quoting unnamed sources, said that Iran had rejected talks about its missile programme, as "non-negotiable".
Meanwhile, Mr Macron said that "we need to be sure Iran will never get nuclear weapons", but he recognised the Iranians would also want "economic compensation of some form" to convince them to agree to additional security demands.
Mr Trump also appeared to be open to this, as he said talks were already under way for other countries to potentially provide Iran with credit, secured by oil, to keep its economy afloat.
The US would not be paying, but there was the possibility of "a letter of credit... from numerous countries", he said.