Ukrainian presidential candidate Volodymyr Zelensky and his wife, Olena, celebrate at campaign headquarters in Kiev after first-round election results are announced. (Genya Savilov/AFP/Getty Images)

THE FACT that the first-round winner in Ukraine’s presidential election is an actor who plays a president in a sitcom could be taken as a sign that the country’s fledgling democracy is dysfunctional. In fact, the success of Volodymyr Zelensky, who is now regarded as the favorite to win the presidency in a runoff later this month, shows that in at least some respects, Ukraine’s political system is working pretty well.

Since rebelling against a corrupt and autocratic regime five years ago, Ukrainians have been deeply frustrated by the failure of their post-revolution government to tackle endemic corruption and implement reforms that would jump-start economic growth. The two most established candidates in the presidential election, including incumbent Petro Poroshenko, offered more of the same. Mr. Poroshenko, a member of Ukraine’s despised oligarch class, has shielded the entrenched interests holding back a country that, despite abundant resources, remains one of the poorest in Europe.

Mr. Zelensky offered voters the option of an untainted outsider — a choice that Russians and citizens of many other post-Soviet states can only dream of. The election that propelled him past 38 other candidates was judged free and mostly fair by international observers, another achievement that will impress Vladi­mir Putin’s subjects. Meanwhile, what was once strong support for candidates who promised fealty to Moscow and its autocratic system all but disappeared. The leading pro-Russian candidate in the race won just 12 percent of the vote.

One reason for that shift was the appeal of Mr. Zelensky. A Russian speaker, he has promised to negotiate with Mr. Putin about ending the five-year-old war in eastern Ukraine while continuing the country’s pro-Western orientation. It’s not at all clear that he would be competent at those difficult tasks, or able to deliver on his promise to tackle corruption and instill the rule of law. The actor has done a good deal of business with one of Ukraine’s most notorious oligarchs, who moved to Israel after being implicated in a major banking scandal.

Mr. Zelensky has taken some reassuring steps, including taking on as advisers prominent reformers who abandoned or were forced out of Mr. Poroshenko’s government. He told Western journalists he feels an affinity with French President Emmanuel Macron. But he also said he admires the Brazilian nationalist Jair Bolsonaro, and diplomats who have spoken with Mr. Zelensky say his knowledge of international affairs is thin.

It’s possible that in the second-round vote Ukrainians will swing back behind the known quantity of Mr. Poroshenko, who has built his campaign around Ukrainian nationalism. Mr. Putin will be hoping for a victory by Mr. Zelensky, whom he could then seek to manipulate. But in one crucial respect, Mr. Putin has already lost the Ukrainian election. A vote Moscow tried and failed to discredit showed that Ukraine is cohering as an independent nation — and that its democracy is working.