RIYADH, Saudi Arabia — A court in Saudi Arabia on Tuesday revised the punishment given to a stateless Palestinian poet convicted of apostasy, reducing it from death to eight years in prison, 800 lashes and public repentance, his lawyer said.

The poet, Ashraf Fayadh, had been sentenced to beheading because of the apostasy conviction announced in November, based partly on his published poetry.

The sentence stirred outrage among international artists and human rights groups at a time when Saudi officials were seeking to rebut comparisons between their application of Sharia law and the practices of the Islamic State extremist group.

The sentence also came near the end of a year in which the Saudi authorities carried out the highest number of executions here in two decades, and just before a mass execution of 47 men on terrorism charges, including a Shiite cleric who had called for the downfall of the royal family.

Mr. Fayadh, 35, was not a known dissident. He was born in Saudi Arabia to a stateless family of Palestinian origin, meaning that has no citizenship; he carries identification documents issued by Egypt.

He was active in Saudi Arabia’s small contemporary arts scene and had worked to make it better known. He curated shows at home and abroad, and in 2013 was interviewed on a Saudi television station about an exhibition he had organized in the Saudi city of Jiddah called Mostly Visible.

His legal troubles began when he was arrested in 2013 in the city of Abha in southwestern Saudi Arabia after an argument in a cafe. He was released without charge, but rearrested later and accused of blasphemy and illicit relationships with women. The charges were based on photographs and the contents of his poetry book published abroad years before, according to court documents.

He was found guilty and sentenced to four years in prison and 800 blows. But that sentence was thrown out on appeal, and Mr. Fayadh was retried and sentenced to death.

While some Saudi officials have said privately that the sentence was too harsh, the kingdom’s judiciary is controlled by deeply conservative clerics who have great latitude to define crimes and issue punishments they deem appropriate.

Saudi courts have given similarly harsh sentences to those they see as a threat to the religious nature of the state. In 2014, they sentenced Raef Badawi, a liberal blogger who had criticized the religious establishment, to 10 years in prison, a large fine and 1,000 blows, to be delivered in multiple floggings. The public administration of the first 50 blows last year caused international condemnation, and Mr. Badawi has not been publicly caned since, although he remains in prison.

Mr. Fayadh’s lawyer, Abdulrahman al-Lahim, appealed the case, and the court announced the new sentence on Tuesday, according to a statement Mr. Lahim posted on his Twitter account.

The statement said the judges still considered Mr. Fayadh guilty but had withdrawn the death penalty, sentencing him instead to eight years in prison and 800 blows, to be administered 50 at a time. Mr. Fayadh would also have to publicly denounce his writings in official Saudi news media, the statement said.

Mr. Lahim said he would file a new appeal.

Saudi officials have not commented on Mr. Fayadh’s case, and they did not respond to requests for comment.

“From our perspective, this shouldn’t even be a case,” said Adam Coogle, a researcher at Human Rights Watch.

“You have gotten rid of the death penalty, which I guess is good, but eight years and 800 blows is a ludicrous price to pay for a speech crime,” he said. PEN America, a press-freedom advocacy group that had publicized Mr. Fayadh’s conviction and punishment, also had a mixed reaction.

“Our relief that Ashraf no longer faces beheading is diminished by the extended injustice and mercilessness of the new sentence dealt to him for the simple human act of artistic expression,” said Karin Deutsch Karlekar, the director of Free Expression Programs at PEN America. “Words do not constitute crimes.”