Pakistan’s general election this week was set to be historic: It was only the second time in Pakistan’s 71-year history that an election was held after a civilian government completed its full five-year term. The scale was huge, with 106 million registered voters, 47 million of whom were women. 370,000 troops were deployed to ensure safety. Dozens of parties and independent candidates were vying for 272 seats in the National Assembly, or lower house of parliament.

But a cloud hung over the election going into polling day. The two main parties vying for power were the incumbent Pakistan Muslim League – Nawaz (PML-N), and the Pakistan Tehreek-e-Insaf (Movement for Justice, or PTI), headed by the former cricket star Imran Khan.

Before his disqualification on charges of corruption last year, three-time Prime Minister Nawaz Sharif had been the country’s most popular politician, but he is now in jail on those charges. His brother, the former Chief Minister of Punjab Shehbaz Sharif, is now heading the PML-N.

Pakistan’s all-powerful military disliked Nawaz—though he had attained political power as a protégé of the military in the mid-1980s. In recent years, two things made him unpalatable to the armed forces: his attempt at friendship with India, and his attempts to call out Pakistan’s security agencies on their support of militant groups. It was the judiciary that ousted him and ultimately indicted him, but many think it was under the influence of the military.

Imran Khan had been railing against Sharif’s corruption for years, an anti-corruption stance being a key element in his party’s agenda. The military is considered to have favoured and bolstered him in recent years. In particular, there were allegations of pre-election manipulation—behind-the-scenes maneuvering to get politicians from Sharif’s party to switch over to Khan’s party or to declare themselves independent.

What Happened On Election Day

Voting on election day itself seemed to go smoothly. Citizens turned out to vote across the country despite a terrorist attack in Quetta that killed more than 30 people. Women turned out to vote in some constituencies where female voter turnout had been zero in 2013. Overall turnout was recorded at 52 percent, compared to a high of 55 percent in 2013. It was a heartening day.

But soon after polls closed and counting began, a whole slew of opposition parties—the PML-N and the Pakistan People’s Party (PPP), as well as smaller parties—started alleging rigging. Vote counts were coming in slowly or not at all, and a number of parties other than the PTI said there had been alarming irregularities, including polling agents from their parties being told to leave polling stations during counting. At the same time, Khan started amassing a sizeable victory, leading in more seats than had been predicted. As of July 27, Khan’s party won 114 out of the 259 seats for which results have been announced, and the PML-N just 63. The PPP bagged 43 seats, and the MMA, an alliance of religious parties, 11.

What really happened after polls closed? Part of the explanation is the Election Commission’s incompetence: Vote counts were slow to come in because the commission’s software crashed. But the alleged irregularities also need to be taken seriously, because established politicians from multiple parties—not just the PML-N, which could be considered a sore loser—are making those allegations. The EU observation mission on Pakistan’s election came out with its preliminary report on July 27, saying this about vote counting procedures: “Counting was sometimes problematic, with EU observers assessing as positive the counting process in two thirds of the observations.” It’s a mixed enough conclusion that both sides—the PTI and opposition parties—can use it, but overall it is arguably better for PTI.

A “Dirty” Election, Or A Mandate?

So was this a “dirty” election, as some have called it, or does Khan have a real mandate? In the run-up to the election, there is no doubt that the lack of a level playing field muddied the election and will continue to be a cloud over it. But in terms of vote outcomes, it is hard to deny that Khan has amassed genuine popularity and a real victory. Given that his party only emerged as a third party on the national scene in 2013, the scale of this victory says something. Khan will easily be able to form government with the support of independent candidates or a smaller party or two. It is a margin that is difficult to explain with post-poll rigging. At the same time, the irregularities must be investigated—and Khan himself said in his conciliatory victory speech that he will partner in any such investigation, which is notable.

Khan’s victory is a story to be studied beyond the military’s support for him. It seems to reflect a changing Pakistan, with changing demographics, young and urban voters, supporting him. It says something about the hopes of Pakistanis and the appeal of a politician who promised a clean government with no excesses for those in public office, a populist who says that he will deliver social services—education and health—for all. It reflects a rejection of the status quo and the established dynastic parties that Pakistanis think have failed to deliver for their country. Whether he will be able to deliver on his massive promises is a question often answered with scepticism. For a long time he was dismissed as politically naïve; it is unclear that he can now surround himself with people who will help him govern.

Khan’s sovereign-nationalist brand of politics and his anti-America bluster have worried many in the West. But in his victory speech, he displayed a more conciliatory tone toward the United States. He said he wants Pakistan to have a “mutually beneficial,” “balanced” relationship with America, not one in which America gives Pakistan aid to help the United States with the war on terror, which he criticises. His view appeals to Pakistanis. Also notably, he struck a conciliatory tone with India in his speech. There is reason to believe that he will be less focused on China than the PML-N. Overall, he indicated an open foreign policy approach, in contrast to his more inward-looking focus in the past.

Most worrisome is Khan’s brand of conservatism—in 2013-2014 he had argued that U.S. drone strikes caused terrorism, and that Pakistan should engage in peace talks with the Pakistan Taliban, which had killed tens of thousands of Pakistanis. In recent years, he has consorted with the far-right and argued in favour of Pakistan’s regressive blasphemy laws. He does not seem to understand the root causes of extremism in the country, nor is it clear at all that he will counter them. He is also not likely to take on Pakistan’s security agencies’ support of non-state militant groups, one of the reasons they seem to have bet on him.

But comparisons made between Khan and Trump—given the right-wing populism of both—lack nuance, as do statements that denounce him as “Taliban Khan”. Khan is many things, both negative and positive. As yet he is largely untested in national office in Pakistan. Whether he can deliver on his well-received victory speech remains to be seen. He’ll also need to be watched closely on his relationship with the far-right—though in Pakistan, the political incentives are always to pander to it. And if he butts heads with the military—on India, on civilian supremacy—he might be in trouble sooner rather than later.

What is clear is that his election represents a change in Pakistan. Interesting times ahead.