Thai voters headed to the polls on Sunday in a hotly contested election that will determine whether Prime Minister Prayuth Chan-ocha, the general who seized power in a coup in 2014, is unseated by his rivals.

An observer of Thai politics has called the election the most consequential one in his lifetime.

Opinion polls show that many voters want change, backing opposition parties that have promised to restore democratic rule in Thailand and roll back some of the authoritarian policies introduced by Mr. Prayuth.

There is a broad sentiment that Mr. Prayuth has done little to boost the economy after nine years in power. His harsh crackdown on pro-democracy protests in Bangkok in 2020 has also alienated many voters.

“If we end up with more or less the same kind of government that we’ve had for years, there’ll be a lot of unhappiness, a lot of grievances in Thailand,” said Thitinan Pongsudhirak, a political scientist at Chulalongkorn University, referring to the country’s economic stagnation.

Here is what you need to know about the election.

Paetongtarn Shinawatra, of the populist Pheu Thai Party, is the current front-runner for prime minister, according to most opinion polls. The 36-year-old — known in Thailand as “Ung Ing” — is the daughter of Thaksin Shinawatra, and much of her appeal rests on her family name.

Mr. Thaksin was prime minister from 2001 to 2006 and is still fondly remembered by many Thais for starting a $1 universal health care program and for distributing subsidies to farmers. Since 2001, the populist political parties he founded, including Pheu Thai, have consistently won the most votes in every election.

But Mr. Thaksin, a billionaire tycoon, remains widely disliked by wealthy conservatives and the military. The army overthrew him in a coup in 2006, and Mr. Thaksin fled the country. (His sister, Yingluck Shinawatra, also met a similar fate eight years later, after her tenure as prime minister.) Mr. Thaksin, who lives mostly in Dubai, was sentenced in absentia to 12 years for corruption and abuse of power.

Ms. Paetongtarn’s rise has fueled questions about whether she would bring her father back to Thailand, and many Thais are now bracing for a possible repeat of the instability that defined the two previous Shinawatra administrations.

Ms. Paetongtarn, who gave birth to a baby boy on May 1 before immediately returning to the campaign trail, is also facing stiff competition from Pita Limjaroenrat, a candidate with the progressive Move Forward Party. In one recent poll, Mr. Pita emerged as the top choice for prime minister.

The prime minister is not selected through popular vote, but by the 500-member House of Representatives and the 250-member military-appointed Senate.

In 2019, the Senate backed Mr. Prayuth unanimously and is likely to align itself with a military proxy candidate again. If it votes as a bloc, an opposition politician would need to cobble together a huge majority in the lower house — at least 376 votes — to lead the country.

Already, Senator Wanchai Sornsiri has said he and a group of fellow senators “definitely would not choose” Ms. Paetongtarn as prime minister. But it remains unclear whom exactly the military would choose.

The vote could be split.

One major surprise this election was the separation of Mr. Prayuth from his comrade-in-arms, Deputy Prime Minister Prawit Wongsuwan. Mr. Prayuth joined the United Thai Nation Party, which was established solely to field him as a candidate in the election. Mr. Prawit stayed with Palang Pracharath, Mr. Prayuth’s former party.

Pheu Thai, the populist party of the former prime minister’s daughter, has been dogged by speculation that it could combine forces to form a coalition with the party of Mr. Prawit. He is widely considered one of the most powerful politicians in Thailand and was the previous army chief under Mr. Thaksin.

Pheu Thai has consistently denied these rumors, but many skeptical Thais say they would vote for the progressive Move Forward Party to prevent such an outcome.

The Move Forward Party has proposed amending a strict law that forbids defaming, insulting or threatening the king and other members of the royal family in Thailand after the authorities charged more than 200 people for violating the law during mass pro-democracy protests in Bangkok in 2020.

Conviction under the law, known as Article 112, carries a minimum sentence of three years and a maximum sentence of up to 15. It is the only crime in Thailand for which a minimum jail term is imposed.

Bread-and-butter issues are also at the forefront of voters’ minds. Thailand’s tourism-dependent economy was hit hard by the coronavirus pandemic, and the country reported the slowest economic growth last year among other major economies in Southeast Asia.

This is why nearly every political party is relying on populist policies, such as cash handouts and subsidies, to lure voters.

If history is any indicator, the military, which has dominated Thai politics for decades, is unlikely to relinquish power easily.

In addition to engineering a dozen coups within a century, Thai generals rewrote the Constitution in 2017 to stack the Senate with allies and ensure that the military would have the power to determine the country’s prime minister.

Even if Mr. Prayuth loses the popular vote, he could still end up with the top job, leading a minority government.

“When everything is so well planned, I don’t think we can be optimistic about change after this election,” said Titipol Phakdeewanich, a political scientist at Ubon Ratchathani University.

In 2020, the country’s Constitutional Court disbanded the Future Forward Party, the previous iteration of the Move Forward Party, after it unexpectedly finished third in the 2019 elections. Mr. Thaksin’s two previous political parties were also dissolved by military leaders. (Conservative officials have also threatened to disband the Move Forward Party this election.)

Wanwichit Boonprong, a political scientist at Rangsit University, said parties have to be wary of the junta’s “stealth authoritarianism” after the election. “This will be the great challenge for the new government,” he said. “Every step will be watched, will be under scrutiny.”

Muktita Suhartono contributed reporting.