DUBAI, United Arab Emirates — Saudi Arabia on Tuesday beheaded 37 Saudi citizens in a mass execution across the country for alleged terrorism-related crimes, publicly pinning one of the headless bodies to a pole as a warning to others.

It marked the largest number of executions in a single day in Saudi Arabia since Jan. 2, 2016, when the kingdom executed 47 individuals, including a prominent Shiite cleric whose death sparked protests in Iran and the ransacking of the Saudi Embassy there.

READ MORE: Why did Saudi Arabia want to silence Jamal Khashoggi?

The executions also come days after four Islamic State gunmen died trying to attack a Saudi security building north of the capital, Riyadh, and on the heels of Easter Day attacks that killed over 300 people in Sri Lanka and were claimed by the Islamic State group.

Saudi Arabia’s Interior Ministry said Tuesday’s executions were carried out in accordance with Islamic law, using language that indicated they were all beheadings. The body of one of the men — Khaled bin Abdel Karim al-Tuwaijri — was publicly pinned to a poll for several hours in a process that is not frequently used by the kingdom and has sparked controversy for its grisly display. The statement did not say in which city of Saudi Arabia the public display took place.

The government defends such executions as a powerful tool for deterrence.

The Interior Ministry statement said those executed had adopted extremist ideologies and formed terrorist cells with the aim of spreading chaos and provoking sectarian strife. It said the individuals had been found guilty according to the law and ordered executed by the Specialized Criminal Court in Riyadh, which specializes in terrorism trials, and the country’s high court.

The individuals were found guilty of attacking security installations with explosives, killing a number of security officers and cooperating with enemy organizations against the interests of the country, the Interior Ministry said.

The government defends such executions as a powerful tool for deterrence.

The statement was carried across state-run media, including the Saudi news channel al-Ekhbariya. The statement read on the state-run news channel opened with a verse from the Quran that condemns attacks that aim to create strife and disharmony and warns of great punishment for those who carry out such attacks.

Those executed hailed from Riyadh, Mecca, Medina and Asir, as well as Shiite Muslim populated areas of the Eastern Province and Qassim. The executions also took place in those various regions.

The statement named all those executed, which included several from large families and tribes in Saudi Arabia.

The mass execution that took place Tuesday was ratified by a royal decree. It comes a day after the Islamic State group said it was behind an attack on Sunday on a Saudi security building in the town of Zulfi in which all four gunmen were killed and three security officers were wounded.

Executions are traditionally carried out after midday prayers. Public displays of the bodies of executed men last for around three hours until late afternoon prayers, with the severed head and body hoisted to the top of a poll overlooking a main square.

Associated Press writer Sam Magdy contributed from Cairo.