Riyadh: 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 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.

Fayadh, 35, was not a known dissident. He was born in Saudi Arabia to a stateless family of Palestinian origin; 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 he was interviewed on a Saudi television station about an exhibition he had organised in the Saudi city of Jeddah 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 Fayadh was retried and sentenced to death.

In 2014, they sentenced Raef Badawi, a liberal blogger who had criticised 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 took place last year, but Badawi has not been publicly caned since, although he remains in prison.

Fayadh’s lawyer, Abdul Rahman Al Lahim, appealed the case, and the court announced the new sentence on Tuesday, according to a statement Lahim posted on his Twitter account.

The statement said the judges still considered 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. Fayadh would also have to publicly denounce his writings in official Saudi news media, the statement said.

Lahim said he would file a new appeal.

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