In the wee hours of Monday morning, Malaysia’s ruling Barisan Nasional coalition won the right to extend its governance to at least 60 uninterrupted years. But in a country where little is straightforward, there are positives in defeat for the opposition — and a growing urban-rural divide that traces racial fault lines.

As the results dribbled in, so did allegations of irregularities. Many Malaysians turned up at polling stations to be told they had already cast a ballot. There were viral reports of phantom voters. The furore over all-too-delible indelible ink descended into typical farce, with authorities’ claims that its strength was affected by halal requirements.

This electoral dodginess is, however, a mere selection of the fauna in the vast forest of Malaysian gerrymandering. The Electoral Commission has not yet released final tallies, but various estimates say Barisan Nasional won 133 seats in Parliament with just 46.5% of the popular vote. With more than 51%, the Pakatan Rakyat opposition coalition won only 89 seats.

Gerrymandering doesn’t easily lend itself to rants on social media, but its lack of visibility is testament to how deeply it is entrenched. A report from before the election pointed out that one rural vote is the equivalent of six urban votes, and that in 2008 Barisan Nasional had won a simple majority in Parliament by the time it had just 18.9% of the popular vote.

The rise of independent news portals and increased social media use — Facebook users, for instance, increased from 3% of the population in 2008 to 47% this year — were seen as a key factor in this election. This contributed to the popularity of Pakatan Rakyat in urban Malaysia, as seen by its wins in Johor and Selangor, the country’s most urbanised states. Rural areas, however, overwhelmingly voted for Barisan Nasional — just as they have always done.

The space between urban and rural Malaysia is set to become the country’s next political battleground. Just as Barisan Nasional will look to win back Malaysians  in the cities over the next five years, Pakatan Rakyat will campaign harder away from its power base. More than one commentator has pointed out that change will be difficult, if not impossible, without Malay support.

While rural voters are predominantly Malay, and Chinese voters are clustered in the country’s urban centres, it was a cross-section of races that contributed to the better opposition showing, including Malaysia’s ethnically Indian population. Analysts have pointed out that middle-class Malay support for Pakatan Rakyat means the swing was predominantly urban in nature. Perceptions of polarisation were not helped by Prime Minister Najib Razak, who managed to dexterously contradict himself by saying his party survived a “Chinese tsunami” while in the same breath pointing out that the racial sentiments played up in the election were “not very healthy for this country”.

“Petitions are being signed, profile pictures are being blacked out, and the tenor of conversation ranges from acceptance of small gains to furious denial.”

Xenophobia, alas, is a renewable resource in Malaysia. In the days leading to the election, an abundance of reports that non-nationals were given identification cards and voting rights led to aggressive posturing online as to how to identify and deal with them, with Bangladeshi nationals the main target. On Sunday, those suspected of being or looking non-Malaysian — the latter a truly arbitrary denomination in an immigrant nation — were confronted and harassed on their way to vote. One man was filmed cowering, in tears, in the back of a car. Others were jeered as they left polling stations.

Malaysia has 3 million migrant workers, predominantly from Bangladesh, Indonesia and India. It is the largest importer of labour in Asia. No matter their origin or status, the treatment of these people came worryingly close to the sort of intolerance Malaysians are trying to vote out of power.

Still, there were encouraging signs. Voter turnout was a record 84.9%. Pakatan Rakyat won seven more seats than it did in 2008, while Barisan Nasional failed to regain the two-thirds parliamentary majority it has used to make unilateral amendments to the constitution.

Pakatan Rakyat leader Anwar Ibrahim had promised to step aside if he lost the election, but yesterday said he might not retire from politics. If he stays, his decision will boost a coalition that at times seemed to be kept together purely by his charisma. The performance of the next generation of opposition politicians, particularly Anwar’s daughter Nurul Izzah, was also promising.

As for Najib, no one can decide if he will stay or be pushed. While Barisan Nasional’s performance was its worst ever, the coalition did win back Malaysia’s rice-bowl state of Kedah from the opposition. Najib has called for reconciliation, but Anwar has been outspoken in his criticism of electoral practices and has called for an assembly on Wednesday. The police have banned celebrations and demonstrations, so the response to the rally will be worth watching.

While some Malaysians celebrate, those likely to turn up in support of Anwar are those who are expressing their disappointment online. Petitions are being signed, profile pictures are being blacked out, and the tenor of conversation ranges from acceptance of small gains to furious denial.

But there is one small irony worth remembering: Barisan Nasional’s manifesto for this election promises rural development. The more wired rural voters are, the more they may be exposed to alternate sources of media and information, and the closer Malaysia may teeter towards maintaining its embryonic two-party system.