KIEV, Ukraine—Three days before Ukraine’s presidential vote last year, employees at the national election commission arrived at work to find their dowdy Soviet-era headquarters transformed into the front line of one of the world’s hottest ongoing cyberwars.

The night before, while the agency’s employees slept, a shadowy pro-Moscow hacking collective called CyberBerkut attacked the premises. Its stated goal: To cripple the online system for distributing results and voter turnout throughout election day. Software was destroyed. Hard drives were fried. Router settings were undone. Even the main backup was ruined.

The carnage stunned computer specialists the next morning. “It was like taking a cold shower,” said Victor Zhora, director of the Ukrainian IT firm Infosafe, which helped set up the network for the elections. “It really was the first strike in the cyberwar.”

In just 72 hours, Ukraine would head to the polls in an election crucial to cementing the legitimacy of a new pro-Western government, desperate for a mandate as war exploded in the country’s east. If the commission didn’t offer its usual real-time online results, doubts about the vote’s legitimacy would further fracture an already divided nation.

The attack ultimately failed to derail the vote. Ukrainian computer specialists mobilized to restore operations in time for the elections. But the intrusion heralded a new era in Ukraine that showed how geopolitical confrontation with Russia could give rise to a nebulous new cabal of cyberfoes, bent on undermining and embarrassing authorities trying to break with the Kremlin.