The New Zealand general election this weekend is the culmination of a campaign that has profoundly shaken this mature, stable and successful country in ways that raise questions about democratic resilience everywhere.

There have been moments in the last six weeks when events appear to have been scripted by the team who write House of Cards. At others, it has seemed that the billionaire internet entrepreneur Kim Dotcom, who is fighting extradition to the US over Megaupload, the file-sharing site on which his fortune is based, is trying to buy the country, or at least the election. His motive, his critics speculate, is to turn NZ into an offshore haven, a place of safety for Julian Assange, Edward Snowden and anyone forced into exile by exposing the inner workings of governments.

Labour and the Greens are demanding a full investigation, yet it still looks likely that the National party incumbent John Key will win a third term, but he will survive with his reputation much diminished. Having started the campaign a clear favourite, a series of scandals has eroded both his own and his party’s standing. The worst, yet to be successfully refuted, were published last month in Dirty Politics, exposing a senior figure on the Key team’s close links with a rightwing blogger that he used to channel smears about rivals into the mainstream press. A fortnight ago, the justice minister, Judith Collins, was forced to step down in the wake of the book’s allegations that she was connected with an attempt to defame the head of the Serious Fraud Office.

The book came shortly after a former mayor of Auckland close to Mr Key, John Banks, was forced to resign following his conviction for a breach of rules on political donations involving Mr Dotcom.

But Mr Dotcom, who is not a New Zealand citizen and cannot become an MP, has a much more direct influence than that. In March he set up the Internet party with more than a £1m of his personal fortune – more than all the other parties have spent on the campaign put together. Earlier this week, he hosted an encrypted video press conference linking Mr Snowden, Glenn Greenwald and Mr Assange in what he dubbed the Moment of Truth, embarrassing Mr Key further with claims (strongly disputed by Mr Key) of his authorisation of mass surveillance by the NSA which Mr Dotcom says he would outlaw. The party’s other pledges on free higher education and fast internet for all look likely to win it a seat or even two in parliament.

Now it is for New Zealand’s voters to decide: they can reject the practitioners of dirty politics. They can resist the disproportionate spending of Mr Dotcom. Their choice ought to define the limits of what is democratic.