The most dangerous country in the world just got considerably more dangerous. Pakistan, home to the fastest growing nuclear weapons arsenal on earth, has broken the decades old domination of its electoral politics by two family dynasties. Imran Khan, a world champion cricketer, is poised to be the next prime minister backed by the powerful army. Khan blames Pakistan’s problems on America and is the most anti-American politician in South Asia.

Imran Khan, 66, is charismatic and bold. He has campaigned for decades to break the logjam of Pakistan’s revolving elections in which either Nawaz Sharif or Benazir Bhutto and her heirs dominate the highest office of the country. Sharif, 65 and a three-time prime minister, is now in jail along with his daughter on trumped-up charges of corruption. Benazir’s son Bilawal, 29, ran an impressive campaign on his own for the first time but came in third place. Khan’s Pakistan Justice Movement (PTI) is leading the parliamentary elections with around 110-120 seats out of 272. Sharif’s party is around 60 and Bhutto at 45. These numbers are not final and there are several independents and small local parties.

Khan will need to persuade independents and small parties to join in a coalition government. He has ruled out working with either Sharif or Bhutto. The horse trading may be prolonged before a government is set—and volatile once created. There are widespread charges of fraud and tampering with the vote. Protests and boycotts are likely. A central question is which party will take control of the Punjab, the country’s largest province and the traditional base of the Sharif clan.

The central platform of Imran Khan’s movement has always been to fight corruption. Pakistan’s politics are certainly full of corruption as is the judicial process. But the most corrupt institution in the country is the army. Pakistani analysts like Aeysha Saddiqa have long documented how the army has become a major land owner and business maestro to enrich the pockets of the officer corps. The generals for decades have manipulated the judicial system to punish their enemies.

There is compelling evidence that the army is supporting Khan, intimidating his opponents and suppressing the press to get him to power. The army soured on Nawaz Sharif years ago and was especially alarmed when he blamed the 2008 Mumbai terrorist attack on the army intelligence service known as the ISI. The ISI was certainly responsible for the Mumbai operation, but to acknowledge that is verboten in Pakistan.

Khan is an outspoken defender of the army and is closely aligned with the Islamist movements patronized by the ISI. He is a frequent critic of the United States which he says treats Pakistan like a “doormat.” Khan says the American war on terror since 9/11 has cost Pakistan billions of dollars and tens of thousands of lives. While domestic violence has gone down in the last couple of years it spiked during the election season.

Pakistan and the United States have had a deeply troubled relationship for decades with great highs and lows. Both sides have used the other and been unreliable partners. Donald Trump’s administration has been outspoken about Pakistan’s connections to terrorism and its support for the Afghan Taliban. Military assistance has been suspended, although the Congress soured on aid for Pakistan in the Obama years.

Imran Khan has said that it would be a “bitter pill” to have to meet with Trump if he Khan is prime minister, but one he would swallow. He probably doesn’t have to worry. South Asia is not a priority for the Trump administration. The president has made clear he wants to bring Americans home from Afghanistan and wash his hands of the war there. His hard line rhetoric on Pakistan is unlikely to persuade Khan and the army to press the Taliban to peace negotiations. So far Trump has been all talk and no action about Pakistan’s ties to terrorism. His generals have persuaded him to stay in Afghanistan, but he is not persuaded they have a viable strategy. He may well be right.

I have been impressed by Khan’s determination when I’ve met him, but also by his proclivity for conspiracy theories no matter how irresponsible. He has a reputation for independence and volatility. His political movement is almost a cult of personality. The generals may find him hard to control.

The election is Pakistan’s second consecutive transfer of power by the ballot box, an important milestone for the country. The democratic process is still weak but it has now produced an outcome not in the old family.

Pakistan desperately needs good governance and a healthy civil-military relationship with the civilians in charge. It needs to abandon terrorism and slow down its nuclear weapons drive to devote attention and resources to development and infrastructure. It is becoming dangerously dependent on China. It has a self interest in warming relations with India. Above all it needs stable and experienced leadership.

None of that seems likely. Get ready for an uncharted future.