Al-Qaeda figure Fares al-Shuwail and Shia leader Nimr al-Nimr, who led anti-government protests, among those executed.
Saudi Arabia has executed 47 "terrorists", according to the interior ministry, including Fares al-Shuwail, a convicted al-Qaeda leader, and Nimr al-Nimr, a Shia religious leader.
In a press statement read out on state TV on Saturday, the Saudi ministry listed the names of all those it said were already convicted on charges of terrorism.
The death sentence given to Nimr al-Nimr, who led anti-government protests in the country's east, was confirmed by the Supreme Court in October.
Faris al-Shuwail had been in custody ever since his detention near the Yemeni border in 2004 [YouTube]
He was convicted of sedition, disobedience and bearing arms. Nimr did not deny the political charges against him, but said he never carried weapons or called for violence.
Many of the other men executed had been linked to attacks in the kingdom between 2003 and 2006, blamed on al-Qaeda.
Shuwail, described by Saudi media as al-Qaeda's top religious leader in the kingdom, was one of them.
He was detained in 2004 while allegedly in possession of weapons.
An Egyptian citizen and a Chadian citizen were also among the executed, the ministry said. The rest were all Saudis.
Reuters news agency reported four of those executed were Shia.
Some were beheaded while others were shot by firing squad, Mansur al-Turki, Saudi interior ministry spokesman, said.
Notably absent from the list was Nimr's nephew, Ali. He was arrested at the age of 17.
Appeal for calm
Nimr's execution prompted calls for demonstrations in Saudi Arabia’s Eastern Province and in other countries of the Middle East, but Mohammed al-Nimr, Nimr's brother, appealed for calm.
"This action will spark anger of [Shia] youths" in Saudi Arabia, but "we reject violence and clashing with authorities", he said.
Nimr spent more than a decade studying theology in predominantly Shia Iran.
In Tehran, images shared on social media appeared to show Iranian protesters breaking into Saudi Arabia's embassy and starting fires, after gathering there to denounce Nimr's execution.
One video posted on Twitter purportedly showed protesters trashing a room while another video outside the embassy building showed small fires burning inside.
Al Jazeera could not immediately verify the authenticity of the images. But a source said that as many as 1,000 protesters had gathered earlier in the night outside the Saudi embassy.
As of 22:00 GMT on Saturday, special police forces had secured the embassy, the source said.
Iran's foreign ministry later called for calm after the protesters had been dispersed by police.
Earlier on Saturday, Iran’s foreign ministry condemned the execution, calling it "the depth of imprudence and irresponsibility" on the part of the Saudi government.
"The Saudi government will pay a heavy price for adopting such policies," Hossein Jaber Ansari, Iran's foreign ministry spokesman, was quoted as saying by the semi-official Fars news agency.
Later on Saturday, the Saudi government summoned the Iranian ambassador to protest against Iran's reaction to the execution.
Hussain al-Shobokshi, a prominent Saudi columnist, told Al Jazeera that Saudi authorities did not differentiate between "Shia source of terror and Sunni source of terror".
"[Saudi Arabia] made sure it saw no difference between any form of terror, as long as it was threatening its people and its economy," he said.
Listen to what Shobokshi told Al Jazeera:
The interior ministry said that those convicted had participated in attacks against residential compounds and government buildings.
Bombings of compounds in Riyadh in May 2003 killed more than 30 people.
The following year there were 30 attacks, which led to a government crackdown on al-Qaeda and other homegrown fighters.
Nimr had called for Eastern Province, an oil-rich region where about two million Shia live, to be separated from the rest of Saudi Arabia.
He also criticised the government for what he said was the marginalisation of the Shia minority in the country.
Friday's announcement came just days after Amnesty International said Saudi Arabia had executed at least 151 people in 2015, the most beheadings in 20 years.
Khalid al-Dakhil, a Saudi political commentator based in Riyadh, challenged "the integrity" of the rights organisation's report, saying it failed to mention Iran's execution record.
"Iran executes far more people a year than Saudi Arabia, but it does not get the negative publicity Saudi Arabia has. This is something that must be addressed," Dakhil told Al Jazeera.
Saudi Arabia said some of those convicted had participated in attacks in Riyadh in 2003 [EPA]
Source: Al Jazeera and agencies