Rouhani will head to Tokyo on Friday in response to the Japanese prime minister's visit to Tehran, Deputy Foreign Minister Seyyed Abbas Araqchi said.
Araqchi said the one-day visit will be "very intense" and that it comes as Iran faces maximum pressure from the United States and a wide array of conspiracies to isolate it internationally.
“When Iran is facing a US policy of maximum pressure and all kinds of plots to isolate Iran, we are witnessing that on the 90th anniversary of the two countries' relations, the heads of (state of) Iran and Japan travel to their capitals,” Araqchi said.
Earlier in the day, Iranian Foreign Ministry spokesman Seyyed Abbas Mousavi told a press conference in Tehran that the "trip (to Japan) is being finalized."
The trip would take place after Rouhani visits Malaysia for a Muslim leaders’ summit in Kuala Lumpur.
Iranian government spokesman Ali Rabiei said discussions would focus on "expanding economic relations" between the two countries.
"Rouhani's trip to Japan has nothing to do with issues such as negotiations with America," Rabiei said.
"However, our Japanese friends usually convey messages or initiatives, which we welcome... and seriously examine," he added, stressing the bilateral focus of the visit.
Rouhani would be the first Iranian president to visit Japan since 2000.
He is set to meet with Prime Minister Abe Shinzo, who traveled to Tehran in June to try to ease tensions between the United States and Iran in the Persian Gulf.
"After Mr. Abe's trip to Iran, it was natural for the president of the Islamic Republic of Iran to have a trip to Japan," Mousavi said.
Talks between the two leaders would focus on "issues and developments in our region, the East Asia region," and the landmark 2015 Iran nuclear deal, Mousavi added.
On December 9, Abe said he was weighing inviting Rouhani for a state visit.
Noting Japan's alliance with the United States and Tokyo's "favorable relations" with Tehran, Abe said he would make efforts "as much as possible to help ease tensions" in the Middle East.
Japan was formerly a major buyer of Iranian crude but stopped purchases to comply with US sanctions imposed after the US unilaterally quit the nuclear deal in May 2018.
AFP contributed to this story.