Bangkok, Thailand — Voters will go to the polls here Sunday at the end of a partisan election campaign that has exposed raw nerves in a deeply divided country and raised fears of further turmoil if the losing side refuses to accept defeat.

Virtually all opinion polls suggest that the opposition Pheu Thai Party (PTP) will beat the ruling party by a wide margin but will need to ally with smaller parties to form the next government. No polls can be published during the final week of the campaign.

An opposition landslide would be a major blow to enemies of exiled former Prime Minister Thaksin Shinawatra, who picked his younger sister, Yingluck Shinawatra, to lead the PTP and remains a key player in Thailand’s internecine politics. Red-shirt fans of Mr. Thaksin last year staged mass protests in Bangkok, provoking an Army-led crackdown that left more than 90 people dead.

Army chief Gen. Prayuth Chan-ocha recently urged Thai voters not to elect “the same people” to run the country, a swipe at Thaksin and his allies who won the past three elections. Prayuth commanded troops in the 2006 coup that ousted Thaksin and is seen as a staunch defender of the monarchy, which has become a target for militant red shirts.

But for all the posturing, the military is unlikely to stage a coup in the election aftermath, though it may try to use other means to thwart a PTP-led government. Another scenario, say analysts, is a return to a cycle of street protests by anti-Thaksin yellow shirts and partisan brinkmanship, particularly if Thaksin returns to Thailand, where he faces a two-year jail term for corruption.

An Army colonel says that Prayuth may strike a compromise with the PTP that keeps him in his current position, installs an ally as Defense minister, and shields his officers from prosecution over last year’s bloodshed. Diplomats say PTP leaders have hinted privately at such an accommodation, even as they publicly insist that no deals are on the table.

But the colonel warns that Thailand’s color-coded polarization would continue and may erupt at any time, whatever short-term deals are struck behind closed doors. The Army “has no good solutions” to the red shirts, he says.

Mr. Hewison said that the ultraconservative People’s Alliance for Democracy (PAD), which is urging a No vote in the election, would be an irritant for any PTP-led government. While recent PAD’s rallies have fizzled, it could count in future on the support of royalists, politicians, and military officers who want to stop Thaksin without resorting to a coup.

“The military doesn’t have to put boots on the ground, but they’ll need feet on the ground, and that means people out demonstrating and opposing [Thaksin],” he says.

Vowed to mobilize if foul play is suspected

For their part, the red shirts have vowed to mobilize against any attempt to rig Sunday’s election in the government’s favor and made clear that they expect the PTP to govern if it wins a plurality of votes. “If we don’t have a clean election, I worry that the violence will come back,” says Toom, a red-shirt activist.

The ruling Democrat Party, which took power in 2008 after the court-ordered dissolution of the previous government, has tried to turn these threats to their advantage by reminding voters of the chaos unleashed by red shirt leaders, some of who are now running for parliament on the PTP’s ticket. One jailed leader, Jatuporn Prompan has been denied bail to campaign.

UN secretary-general Ban Ki-moon said Wednesday that he hoped for a “fair, credible, and transparent” election and urged all parties to respect the will of the people. Western diplomats in Bangkok say they have conveyed similar messages to all sides.

Speaking recently to foreign correspondents, Prime Minister Abhisit Vejjajiva said he would accept defeat at the ballot box and defended his record as a parliamentary democrat. “I don’t see any reason why there has to be unrest. If the elections are free and fair, and the parliamentary process goes ahead, all people should accept that,” he said.

Fluid battleground

Thailand’s next parliament will have 500 seats, up from 480 at the 2007 election in which the PTP’s predecessor won 233 seats. Of the total seats, 125 will be drawn from a party list based on a national ballot, with the rest elected by districts.

While some regions lean strongly toward certain parties, Bangkok is considered a fluid battleground. In 2007, the Democrats won most seats in the capital, but polls show that the PTP has an edge in many districts. Both main parties are staging final rallies Friday night in the capital, which is festooned with party posters and other political advertisements.

“I’m confident that we can win in Bangkok,” says Korbsak Sabhavasu, campaign manager for the Democrats and a senior aide to Mr. Abhisit. He says that most voters have already made up their minds by now, and that the final tally would be close.