Saudi Arabia scrambled on Friday to withdraw a school textbook that accidentally included a doctored photograph of a former ruler sitting next to a "Star Wars" character, prompting ridicule on social media.

The black-and-white image shows King Faisal, Saudi Arabia's third monarch, signing the United Nations Charter in 1945, with the diminutive Jedi master Yoda perched next to him.

The image was created by 26-year-old Saudi artist Abdullah al-Shehri, who has gained renown for mixing pop culture icons into historic photographs.

Saudi textbooks withdrawn after chapter on UN found with picture of Yoda with the king. https://t.co/BVUJzD2MFT pic.twitter.com/HCqc3mQwP1 — Mohamed Nanabhay (@mohamed) September 22, 2017

"The Ministry of Education regrets the inadvertent error," Saudi Education Minister Ahmed al-Eissa said on Twitter.

He said the ministry had begun recalling the textbook and printing a corrected version, adding that a legal committee would be formed to determine the source of the error.

Al-Sheri told the New York Times that he was surprised to see the photograph end up in the school textbook.

He said he paired the king and Yoda as they were both intelligent and because Yoda's green skin and light saber matched the green of the Saudi flag.

He stressed he had meant no offence to the king, seen widely as the architect of Saudi Arabia's modernisation.

But the error prompted light-hearted banter on social media.

One Saudi schoolteacher jested that this error symbolised "payback" after the education ministry introduced an extra hour of classes in schools earlier this year.