When Thais go to the polls on Sunday, they will be voting in a closely fought election that is seen, in part, as a referendum on whether it is illegal to criticize the Thai monarchy.

Thailand has one of the world’s strictest laws against defaming or insulting the king and other members of the royal family. Once considered taboo, the topic of the monarchy was brought to the forefront after tens of thousands of protesters took to the streets and called for checks on the institution’s power in 2020.

The protests represented two sides of an impassioned struggle to determine the role of the crown in modern Thailand. The election could determine whether the Southeast Asian nation of 72 million will revive its once-vibrant democracy or slide further toward authoritarian rule, with royalists firmly in power.

On one side of the debate are conservative political parties whose standard-bearer is Prime Minister Prayuth Chan-ocha, the general who has governed Thailand for nine years after seizing power in a coup. He and his supporters argue that amending the law could lead to abolishing the monarchy altogether, and have vowed to defend the royal family.

On the other side is the progressive Move Forward Party, which is polling in second place and argues that the law needs to be amended because it is being used as a political weapon. Several young people who participated in the 2020 protests are now running as candidates with the Move Forward Party.

“Perhaps one of the deepest fault lines in Thai society is about the monarchy,” said Sunai Phasuk, a senior researcher on Thailand for Human Rights Watch.

Paetongtarn Shinawatra, the youngest daughter of the ousted former Prime Minister Thaksin Shinawatra and the front-runner for prime minister, is treading carefully. Her father, a populist billionaire, is one of the most divisive political figures in Thailand. He lives in self-exile after being ousted in a coup in 2006 and can only return to Thailand with the king’s permission.

Royalists have consistently accused Mr. Thaksin of wanting to overthrow the monarchy, a charge that he denies. Ms. Paetongtarn has said her party, Pheu Thai, would not abolish the law protecting the monarchy from criticism, but that the issue of reform must be openly discussed in Parliament.

Opinion polls show that the party of Mr. Prayuth, United Thai Nation, is trailing in third place behind Pheu Thai, which has topped the polls. In recent weeks, there has also been a surge in support for the Move Forward Party, which is polling a close No. 2.

Move Forward is the largest party pushing to amend the law, irking conservatives who have accused it of undermining the monarchy. The party wants to cut the jail terms of violators of the law and designate the Bureau of the Royal Household as the only agency allowed to file lawsuits. (Any Thai citizen is able to file complaints under the current version of the law.)

Conservative politicians have threatened to disband Move Forward. The party’s previous iteration, the Future Forward Party, was dissolved in 2020 by the Constitutional Court. In a sign of how sensitive the topic of reform has become, Move Forward has attempted to moderate its position, saying reform would not take precedence in its campaign.

For decades, the monarchy and the military have had a symbiotic relationship, with the army frequently reminding the public that it is the true guardian of the Thai crown. Thais are taught from a young age that they have to love the king and that any criticism of the monarchy is strictly forbidden.

But today, many Thais no longer stand at attention when the royal anthem is played in public spaces such as movie theaters. Royalist Marketplace, a Facebook group set up to satirize the monarchy, had more than 1 million members before Facebook blocked access to it in 2020, citing a Thai government request.

The law criminalizing criticism of the monarchy carries a minimum sentence of three years if violated — the only law in Thailand that imposes a minimum jail term — and a maximum sentence of up to 15 years. After the 2020 protests, the authorities charged at least 223 people, including 17 minors, for violating the law, known as Article 112.

Tantawan “Tawan” Tuatulanon, a 21-year-old law student, was accused of violating the rule in 2022 after she and her friends conducted a poll asking whether the royal motorcade was an inconvenience to Bangkok residents.

In recent weeks, she has been pressing political parties on whether they would amend the law — which she is in favor of abolishing — after the election. On Wednesday, Ms. Tantawan was arrested after she called for the release of a 15-year-old charged with violating the rule.

“I feel we don’t need any law that specially protects anybody or any family,” said Ms. Tantawan, who mounted a hunger strike earlier this year in protest against the government. “He is a person like us, not a god or a demigod.”

King Maha Vajiralongkorn Bodindradebayavarangkun, who ascended the throne in 2016, is not as beloved as his father, King Bhumibol Adulyadej, who reigned for 70 years. While King Bhumibol was revered in Thailand, his son used to spend most of his time in Germany, though he has been seen more often in public since the 2020 protests.

In the wake of the protests, Mr. Prayuth instructed all government officials to “use every single law” to prosecute anyone who criticized the monarchy. Royalists stepped up their campaign against people they accused of insulting the crown, filing more complaints and attacking anti-monarchy activists.

In 2021, Warong Dechgitvigrom, a former doctor, founded Thailand’s first far-right party, Thai Pakdee, in response to what he called the “Three Fingers Mob,” referring to the three-finger salute adopted by young Thais as a symbol of resistance during the 2020 protests.

He now says the current law protecting the monarchy does not go far enough, as it is limited to shielding four key members of the royal family. Former Thai kings, princes, princesses and the word “monarchy” itself should also be protected, he said.

Although Mr. Warong’s views are considered extreme, he says he has collected about 6,000 to 7,000 signatures for his proposal, and that he is confident he can gather the 10,000 signatures needed for the House of Representatives to consider passing the bill.

Mr. Warong says people need to understand that the Thai monarchy is unique. He recalled France’s former monarchy as one characterized by the oppression of its people. “But ours is like father and children,” he said. “We have good feelings together, there are no bad feelings.”

Those views are at odds with how many young people feel about the king. During the 2020 demonstrations, protesters questioned the wealth of the royal family, which is one of the richest in the world.

Kasit Piromya, a former foreign minister, said it would be challenging for Mr. Warong and his party to lead a successful campaign backing the constitutional monarchy because many young people “don’t see what is in it for them.”

“If you cannot speak this in the open, then it gives more room and ammunition to the students, to the Thaksin supporters to say, ‘We are more democratic,’” Mr. Kasit said, referring to calls to reform the monarchy.

Arnond Sakworawich, an assistant professor of statistics at the National Institute of Development Administration, said that preserving Article 112 was necessary because the king and the royal family do not defend themselves against criticism.

“It’s a different culture, because in Thailand, people believe that the king is their parent, and parents never hurt their children,” said Mr. Arnond, who is known for his royalist views. “So there must be some people to protect the king.”

In their zeal to defend the monarchy, many royalists may ultimately end up hurting the institution more than they protect it.

Siripan Nogsuan Sawasdee, the head of the department of government at Chulalongkorn University, said it was “very precarious and risky” for parties such as Thai Pakdee to use the monarchy as a campaigning platform.

“Even though the monarchy is above politics, it’s now drawn into the divide,” she said. “It will polarize the voters and parties into two camps, inevitably.”

Ryn Jirenuwat contributed reporting.