The Indian Ocean nation of the Maldives, comprising 1,190 coral atolls, has been roiled by a deepening national crisis since its first democratically-elected president was forced to resign at gunpoint in 2012.

The surprise defeat of authoritarian President Abdulla Yameen in the Sept. 23 national election opens the path to stability and reconciliation under the leadership of the winning opposition candidate Ibrahim Mohamed Solih.

Yameen's defeat, despite the jailing of opponents and Supreme Court justices and efforts to manipulate the election, shows how autocrats can be swept out of office by a voters' backlash. And that even in a country with weak democratic traditions.

The Maldives follows Malaysia, where, in May, Prime Minister Najib Razak was voted out and now faces corruption charges under his 93-year-old successor, Mahathir Mohamad. Sri Lanka's voters in 2015 similarly ended the quasi-dictatorship of President Mahinda Rajapaksa, who curtailed media freedom.

In all three states, China's shadow loomed large. Yameen signed major financing and investment deals with China and, like Najib and Rajapaksa, is alleged by his opponents to have received Chinese funds for his reelection bid.

While Malaysian investigators are probing whether China helped bankroll Najib's reelection bid, The New York Times reported in June that the state-run China Harbor Engineering Company allegedly gave $7.6 million for Rajapaksa's campaign. Rajapaksa and CHEC have denied the claim, but new president Maithripala Sirisena's government has called for an investigation.

China, Yameen's main defender, capitalized on its support to expand its influence in the strategic Maldivian archipelago. Yameen, for his part, felt emboldened by Chinese support to crack down on the opposition and undermine national institutions, including the judiciary and the election commission.

With barely 450,000 citizens, the Maldives is tiny but sits astride critical shipping lanes, making it vital to security in the Indian Ocean. Yameen's rout thus is a setback to China's maritime ambitions and political influence, and a victory for grass roots democratic forces.

At a time when Beijing is beginning to encounter a wider pushback against its Belt and Road Initiative -- an influence-building infrastructure program that can ensnare vulnerable countries in debt traps -- the Maldives represents the latest case of a democratic election upending China's plans. BRI could face speed bumps even in China's close ally, Pakistan, where the new, cash-strapped government has instituted a review of Chinese projects.

China, however, can take comfort from the formation of a friendly, democratically elected communist government in the Himalayan state of Nepal. In a demonstration of autocratic China's ability to exploit the openness of a democracy, it helped unite warring communist factions in Nepal and funded their election campaign.

In the Maldives, pressure from democratic powers, including the specter of an Indian military intervention, played a role in the outcome. The U.S. had warned of "appropriate measures" and the European Union had threatened sanctions if the vote was not free and fair. And when Yameen hesitated to concede defeat, Washington demanded he "respect the will of the people," while India sought to present a fait accompli by being first to congratulate his opponent, Solih. (In the previous election in 2013, Yameen got the Supreme Court to annul the result after he trailed his opponent, forcing fresh polls which he dubiously won.)

India has traditionally viewed the Maldives as in its sphere of influence. So as China began eroding Indian influence by backing Yameen from 2013, concern grew in New Delhi that Beijing could turn one of the unpopulated Maldivian islands it had leased into a naval base, completing a strategic encirclement of India.

Among the islands China has acquired is Feydhoo Finolhu, for which it paid $4 million, less than the cost of a luxury apartment in Hong Kong; another island, the 7km-long Kalhufahalufushi, came even cheaper. China has revealed its strategic intentions by sending frigates to the Maldives.

After Yameen in February declared a state of emergency and jailed Supreme Court justices for quashing convictions against nine jailed or exiled opposition figures, India came under pressure, including from the Maldivian opposition, to intervene militarily, as it did once before - in 1988 when it foiled an attempted coup. The Indian intervention helped President Maumoon Abdul Gayoom to perpetuate his soft autocracy for another two decades.

An intervention this year, however, would have been dicey, not least because no legitimate authority had invited India to send in forces. The intervention could have provoked a nationalistic backlash and strengthened Islamist forces in the Maldives, which has supplied the world's highest per capita number of foreign fighters to terrorist groups in Syria and Iraq. By correctly erring on the side of caution, India aided the electoral outcome.

The restoration of full democracy in the Maldives, like in Malaysia, bucks an international trend: The global spread of democracy has largely stalled, with liberal forces unable to gain ground in the face of both tightly centralized political systems (as in China) and a revival of authoritarianism (as in Russia). While democracy has become the norm in large parts of Europe, very few Asian states are true democracies.

The return of democracy to the Maldives is especially remarkable as the country has been under authoritarianism for 50 of the 53 years since gaining independence from Britain in 1965. Yameen's five-year rule marked a shift to hard authoritarianism, with that lurch being accompanied by the rising power of Islamists.

In the latest election, Yameen chose as his running mate a Muslim preacher with close ties to Saudi groups and got support from Jamiyyath Salaf. This extremist organization was one of the Islamist groups behind the 2012 museum attack that erased evidence of the country's pre-Islamic past by destroying priceless Buddhist and Hindu statues.

The triumph of democratic forces, however, cannot mask the tough challenges that await Yameen's successor, Solih, including on how to deal with Islamist power and service Chinese debt (which currently equals more than a quarter of the country's gross domestic product). One key question is whether the Maldives will be able to pull back from the brink of a Chinese debt trap (by emulating the example set by Mahathir, who has canceled Chinese projects) or whether it is so indebted - as Sri Lanka is -- that it will remain under Beijing's sway.

China invested heavily in Sri Lanka during the rule of Rajapaksa, whom it shielded at the United Nations from allegations of war crimes. Sirisena sought to extricate Sri Lanka from the Chinese debt trap, including suspending work on major projects. But it was too late: Saddled with debts his government could not repay, Sirisena was forced to accept Chinese demands, including restarting suspended projects and handing the strategic Hambantota port to China on a 99-year lease.

Under Solih, even without new contracts, the Maldives' debt to China will rise because of the Chinese projects already initiated. Beijing will court Solih -- to be sworn in on Nov. 17 -- just as it has wooed Sirisena, who has disclosed that China has "gifted" him $300 million "for any project of my wish," besides constructing South Asia's largest kidney hospital in his home district.

To reclaim its influence in the Maldives, India will have to do more than help strengthen the restored democracy; it must assist the new government in infrastructure development and meeting its foreign debt obligations, including by extending low-interest loans to pay off Chinese credits. Escaping debt entrapment is vital for the Maldives to retain strategic autonomy.

Brahma Chellaney is a geostrategist and the author, most recently, of the award-winning "Water, Peace, and War."