In announcing its decision, Qatar made no mention of the diplomatic crisis roiling Gulf Arab nations since June, when Doha found its land, sea and air routes cut off by the four Arab states.
Iran, which welcomed Doha's decision, has sent food to Qatar and allowed its airplanes to increasingly use the Islamic Republic's airspace.
Restoring diplomatic ties will undoubtedly anger those opposing Qatar in the regional dispute, chief among them Saudi Arabia, Iran's regional rival.
"Qatar has shown it is going to go in a different direction," said Kristian Coates Ulrichsen, a research fellow at the James A. Baker III Institute for Public Policy at Rice University who lives in Seattle.
More From This Section
"It could very well be calculated toward reinforcing the point that Qatar will not bow to this regional pressure placed upon it."
Qatar pulled its ambassador from Tehran in early 2016 after Saudi Arabia's execution of a prominent Shiite cleric sparked attacks on two Saudi diplomatic posts in Iran, a move to show solidarity with the kingdom.
"The state of Qatar expressed its aspiration to strengthen bilateral relations with the Islamic Republic of Iran in all fields," the statement said.
In Iran, Foreign Ministry spokesman Bahram Ghasemi said Qatar announced its intention to return its ambassador to Tehran in a phone with Foreign Minister Mohammad Javad Zarif.
"We welcome this measure by the Qatari government," Ghasemi said, according to the state-run IRNA news agency.
Despite recalling its ambassador in 2016, Qatar maintained its valuable commercial ties to Iran. Qatar and Iran share a massive offshore natural gas field, called the South Pars Field by Tehran and the North Field by Doha.
Shiite power Iran also has incorporated the crisis into its regular criticism of the Sunni-ruled Saudi Arabia, part of the two Mideast powers' long-running proxy war.
However, those tensions may be easing as well, as Iran's semi-official ISNA news agency quoted Zarif as saying visas for both Iranian and Saudi diplomats to visit their respective embassies and consulates had been issued.
Zarif said final steps to allow the visits likely would be taken after the annual hajj pilgrimage at the end of the month.
The diplomatic crisis began on June 5, when Bahrain, Egypt, Saudi Arabia and the United Arab Emirates cut ties to Qatar over allegations it was funding extremists and being too close to Iran.
Qatar long has denied funding extremists. The boycotting countries later issued a list of 13 demands to Qatar, including that Doha shut its diplomatic posts in Iran. Qatar ignored the demands and let a deadline to comply pass, creating an apparent stalemate in the crisis.