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.
More From This Section
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".
Iranian foreign ministry spokesman Abbas Araqchi was quoted by the ISNA news agency as calling the Saudi move "very unfortunate", and adding that Tehran was investigating.
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.
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.