Speaking to British television station ITV in an interview published on Wednesday, the U.S. president said: "Iran is a place that was extremely hostile when I first came into office... They were a terrorist nation, number one in the world at that time and probably maybe are today."
When asked whether he thought he would need to take military action against Iran, Trump replied: "There is always a chance. Do I want to? No, I'd rather not. But there's always a chance."
Later in the interview, when asked if he would prefer to hold talks with Iran's president, Trump said: "Yeah, of course. I would much rather talk."
Iran and the U.S. have been drawn into starker confrontation in recent weeks, stoking concerns about a potential conflict.
It comes a year after Washington pulled out of a deal between Tehran and global powers to curb its nuclear program in return for lifting international sanctions.
The U.S. re-imposed sanctions on Iran last year, before ratcheting them up further in May, ordering all countries to cut off imports of Iranian oil.
In the past month, the U.S. has hinted at military action in Iran while the Trump administration has said it has built up its military presence in the region.
On Saturday, Iran's President Hassan Rouhani suggested Tehran would be willing to hold talks if Washington showed respect, but the country would not be pressured into talks.
Trump's comments about tensions with Iran come as he prepares for the final day of his three-day state visit to Britain.
The U.S. president's trip has been dominated with a series of official engagements with Queen Elizabeth II and Prime Minister Theresa May.
On Wednesday, Trump will accompany members of the British royal family at an official event commemorating the 75th anniversary of the D-Day landings in Portsmouth.
Later, he will travel to Normandy to attend another D-Day ceremony in France with President Emmanuel Macron.