Saudi Arabia denied permission for a plane carrying Sudanese President Omar al-Bashir to cross its airspace on Sunday for the swearing-in of the new Iranian president, Khartoum said.
The aircraft had to turn back.
"The Saudi authorities refused to give the plane carrying President Bashir permission to cross their airspace," Emad Sayed Ahmed, the presidential press secretary, told AFP.
Saudi Arabia, a Sunni Muslim kingdom, has repeatedly voiced fears about the controversial nuclear programme of Shiite-dominated Iran, whose warships twice docked in Sudan late last year.
Khartoum has tried to balance ties with both Tehran and Riyadh.
Ahmed said Bashir was not flying in his normal presidential aircraft but was using a plane rented from a Saudi company.
Sudan's leader was travelling to attend President Hassan Rowhani's swearing-in before the Iranian parliament.
The moderate Rowhani later took the oath at a ceremony attended for the first time by foreign dignitaries including regional leaders -- but without Bashir.
Ahmed said that when Bashir's plane entered Saudi airspace the pilot informed authorities that it had approval "and that it was carrying Sudan's leader.
"But they said the plane didn't have permission," forcing it to return to Khartoum, he said.
The official SUNA news agency had sent a brief SMS alert at 0706 GMT announcing that Bashir "leaves for Tehran on an official two-day visit to Iran".
The Hague-based International Criminal Court in 2009 and 2010 issued two warrants against Bashir for war crimes, crimes against humanity and genocide over the conflict in Sudan's Darfur region.
Khartoum's links with Iran came under scrutiny after Bashir's regime accused Israel of an October 23 strike against the Yarmouk military factory in the capital, which led to speculation that Iranian weapons were stored or manufactured there.
Israel refused all comment on Sudan's accusation about the factory blast.
But a top Israeli defence official, Amos Gilad, said Sudan "serves as a route for the transfer, via Egyptian territory, of Iranian weapons to Hamas and Islamic Jihad terrorists".
Later in October two Iranian navy vessels called at Port Sudan, followed by two more in December, in what Khartoum described as a "normal" port stop.
At the same time, Sudan courts Saudi investment and many Sudanese work in the kingdom, having abandoned their impoverished homeland and its economic crisis for better opportunities abroad.
Bashir himself underwent minor surgery in Saudi Arabia last November.
A regional analyst predicted that barring Bashir's plane will spark "a diplomatic crisis" between Tehran and Riyadh but will cause only a minor irritation in Saudi-Sudanese relations.
"President Bashir will be upset but he needs the Saudi government. He needs money. He needs political support," the analyst said, asking not to be named.
"I think the Saudi authorities will continue to support Bashir's regime, for sure."
Rowhani takes over from his predecessor Mahmoud Ahmadinejad, whose provocative policies in two turbulent four-year terms left Iran isolated internationally and struggling economically.