Iran's Mahmoud Ahmadinejad will this week become the first sitting president of the Islamic republic to perform the pilgrimage to Mecca, his office said.
It will be Mr Ahmadinejad's third visit to Saudi Arabia, seat of the Kaaba
It follows a formal invitation from King Abdullah of Saudi Arabia, seat of the Islamic holy places and a long-time regional rival of revolutionary Iran.
It is not clear if he has performed the Hajj before, or if past presidents have been to Mecca after leaving office.
An official said the invitation was an important event in Saudi-Iranian ties.
"It is the first time in the history of relations between Iran and Saudi Arabia that the king of this country invites a president of the Islamic republic to make the pilgrimage to Mecca," said presidential aide Ali Akbar Javanfekr.
Relations between revolutionary, Shia Iran and the conservative, Sunni monarchy of Saudi Arabia have been steadily improving since the first visit to Riyadh by an Iranian president in 1999.
Twelve years earlier, more than 400 people, mostly Iranians, were killed in clashes between Iranians and Saudi security forces during the Hajj.
Earlier this month Mr Ahmadinejad became the first Iranian president to attend the annual summit of six Arab Gulf states - all strong US allies - in neighbouring Qatar.
Iran and Mr Ahmadinejad in particular are among Washington's most vocal critics in the region.
It will be his third visit to Saudi Arabia as president.
The pilgrimage rites, which last for five days and are performed by at least 1.5 million Muslims, are expected to begin on 18 December.