Thai Prime Minister Abhisit Vejjajiva gestures to media prior to leaving Government House in Bangkok on May 9. Thailand's general election will be held on July 3 after the king endorsed a royal decree to dissolve the lower house, the government spokesman said.

Bangkok, Thailand — Thailand’s government today said it would hold national elections July 3, setting the stage for a high-stakes contest between bitter political rivals in a shaky democracy polarized along class and regional lines.

Prime Minister Abhisit Vejjajiva on Monday announced the dissolution of parliament in a televised address after Thailand’s ailing monarch endorsed the election plan. "I want to see this country move forward," Mr. Abhisit said.

It would be the first election since 2007, when Thailand was under military rule. Abhisit was installed a year later with military backing after the collapse of a popularly elected government and has struggled ever since to assert his legitimacy to lead a divided country.

Abhisit’s Democrat Party broadly enjoys the support of voters in Bangkok and southern areas but is less popular in the hardscrabble north and northeast. In these areas, allies of former Prime Minister Thaksin Shinawatra are expected to capitalize on anger over the violent military crackdown last year on anti-government demonstrations that killed at least 90 people. Mr. Thaksin, who lives in exile in Dubai, was ousted in a 2006 coup and later sentenced to jail for abusing his power, but remains formidable.

A spate of opinion polls have suggested that the pro-Thaksin Pua Thai Party would win the largest representation in the 500-seat parliament, though a significant number of voters identified themselves as undecided. Still, no party is expected to win an overall majority, so a coalition is the most likely outcome.

Observers say that the bitter rivalry between political groups, and the risk that neither would accept defeat, has increased the stakes. A coalition of academics and peace activists recently persuaded nine political parties to sign a pre-election code of conduct that includes pledges to cool rhetoric and not disrupt rivals’ campaign activities.

Gothom Arya, a former election commissioner who helped draw up the code of conduct, said that tensions could rise after the campaign is over. “We have a possibility, perhaps in the post-election period, of a renewal of confrontation in the streets, as we’ve seen off and on for the past five years,” he says.

In recent months, the ultra-nationalist People’s Alliance for Democracy (PAD) has held rallies over an alleged loss of territory to Cambodia. Troops from the two countries have clashed repeatedly along their land border, mostly near a disputed temple. The PAD, which occupied Bangkok’s airports in 2008, is urging supporters to boycott the election.

In contrast, Thaksin’s red-shirted supporters are expected to be active in rallying the opposition’s base. Several red-shirt leaders have been charged with terrorism offenses over last year’s chaotic protests and also face accusations of defaming the monarch, which carries a 15-year jail sentence.

Mr. Gothom said that he had invited the group’s leaders to join a signing ceremony on Wednesday for the electoral code of conduct. But it was unclear if they would attend.

Sign up for our daily World Editor's Picks newsletter. Our best stories, in your inbox.