POLTAVA, Ukraine — After four years of investigation by the German police, the F.B.I. and other crime-fighting agencies around the world, heavily armed security officers stormed an apartment in the central Ukrainian town of Poltava. After a brief exchange of gunfire, they captured their prey: the man suspected of leading a cybercrime gang accused of stealing more than $100 million.
The arrest of Gennadi Kapkanov, 33, a Russian-born Ukrainian hacker, and the takedown of Avalanche, a vast network of computers he and his confederates were accused of hijacking through malware and turning into a global criminal enterprise, won a rare round of applause for Ukraine from its frequently dispirited Western backers.
By the following day, however, Mr. Kapkanov had disappeared.
A judge in a district court in Poltava turned down a prosecution request that he be held in preventive custody for 40 days, and ordered him set free. Mr. Kapkanov has not been seen since.
Whether Mr. Kapkanov’s flight was the result of corruption, incompetence or a mix of the two has not been clearly established. The prosecutor general in Kiev, Ukraine’s capital, threatened to fire the local prosecutor but backed off when it became clear that the case had been handled by one of his own deputies.
The Poltava debacle helps explain why Ukraine, a land of so much promise thanks to its educated population, fertile farmland and vibrant civil society, has a tendency instead to generate so many headline-grabbing scandals.
Over the past year, Ukraine has been battered by revelations: off-the-books payments to President Trump’s former campaign manager, Paul Manafort; the creation in Ukraine of malware used in hacking attacks by Russia during the 2016 American presidential election; and speculation that its Soviet-era missile technology may have been smuggled to North Korea.
The sagas are unrelated in their substance and timing. Mr. Manafort’s activities in Ukraine predate Ukraine’s 2014 revolution, while the others follow it. But they all flow in part from the same dysfunctions of a weak state gnawed by corruption and thrown off balance by constant Russian pressure, and the open vistas of opportunity for skulduggery that these have offered.
“Why is there so much noise around Ukraine? Because Ukraine is the epicenter of the confrontation between the Western democratic world and authoritarian, totalitarian states,” Oleksandr Turchynov, the head of Ukraine’s national security and defense council, said in an interview. He denounced reports of Ukraine providing missiles to North Korea as Russian disinformation aimed at undermining Western support.
But while Russia has worked steadily since the 1991 collapse of the Soviet Union to weaken Ukraine and keep it within Moscow’s orbit of influence — first through economic pressure and political meddling and then military aggression — Ukraine has also enfeebled itself.
“The thread that ties strange things together in Ukraine is nearly always corruption,” said Serhiy A. Leshchenko, an opposition member of the Ukrainian Parliament and vociferous critic of President Petro O. Poroshenko.
Mr. Poroshenko, he conceded, is better than his predecessor, the kleptocratic, pro-Russian leader — and former Manafort client — Viktor F. Yanukovych, who fled to Russia in February 2014 after months of street protests in Kiev. “But that is only because he is weaker, and society is much stronger,” Mr. Leshchenko said.
Mr. Poroshenko, unlike his Russian counterpart, President Vladimir V. Putin, also has to contend with a lively free press that delights in probing and exposing government stumbles and the maneuvers of self-dealing insiders.
“Ukraine, with the exception of the Baltic States, is the only post-Soviet republic which is not authoritarian,” said Serhii Plokhii, a Harvard professor and the author of a history of Ukraine. And unlike the three Baltic States, which enjoyed brief periods of independence between the First and Second World Wars, Ukraine has only an acute awareness of centuries of subjugation by outside powers, among them Poland, Austria and Russia, that left its people inherently wary of authority.
“What is Ukraine’s national idea? It is resistance to authority,” said Taras Chornovil, a former adviser to Mr. Yanukovych.
Ukraine’s painful history as a put-upon appendage has left it ill-equipped to curb unruly habits at odds with the rule-based, scandal-shy order of the European Union, which it aspires to join.
“Its attempts to stay democratic while building a nation are often messy, its oligarchs all powerful and, given the virtual absence of state control over media and oligarchic competition, post-Soviet corruption is out in the open,” Mr. Plokhii said.
Ukraine’s domestic intelligence service, or S.B.U., its powers of surveillance greatly enhanced by monitoring equipment provided by the United States after Mr. Yanukovych decamped to Russia, has added its own highly selective and distorted form of transparency by leaking information about alleged wrongdoing, often for political or financial gain.
Controlled by Mr. Poroshenko, the S.B.U. has become a tool in domestic political and business battles, with anti-corruption activists accusing it of working to undermine, not help, their cause.
While still politically influenced, Ukrainian law enforcement is no longer the swamp of incompetence and corruption it once was. It has been able to monitor Mr. Manafort’s former business associates and turn up evidence of Russian hacking in the 2016 United States election, in part owing to American technical support.
The Central Intelligence Agency tore out a Russian-provided cellphone surveillance system, and put in American-supplied computers, said Viktoria Gorbuz, a former head of a liaison office at the S.B.U. that worked with foreign governments.
Ms. Gorbuz’s department translated telephone intercepts from the new system and forwarded them to the Americans. “This team would translate and immediately, 24 hours a day, be in full cooperation with our American colleagues,” she said.
It is unclear whether any phone intercepts relevant to the election meddling investigation have gone to the American authorities. But a Ukrainian law enforcement official has given journalists partial phone records of former associates of Mr. Manafort.
Dismantling Russian spy gear, however, proved far easier than purging Russian power, which has shadowed Ukraine constantly since it declared independence in 1991 but became far more aggressive in recent years.
Since March 2014 Ukraine has lost Crimea to Russian annexation and large chunks of its industrial heartland in the east to rebels backed by fighters and weapons from Russia. It has also been used as a testing ground by Moscow for disinformation and hacking techniques later deployed during presidential election campaigns in the United States and France.
Ukrainian officials invariably cite Russian meddling to explain why anti-corruption and other steps demanded by the West have often faltered. While Russia is a convenient excuse, it is also a very real menace.
In Poltava, the center of town is dominated by a czarist-era monument to Russia’s victory over Sweden in a 1709 battle that sealed Russia’s rise as the region’s pre-eminent power and ended Ukrainians’ early aspirations for their own state.
Now draped in Ukrainian flags, the monument nonetheless stands as a powerful reminder of Russia’s looming presence in a country that has struggled to create a functioning independent state on the fragile foundations left by more than 70 years of communism and centuries of subjugation by Russian czars.
Igor Gavrilenko, a lecturer in Ukrainian history at the Poltava National Technical University, said the release of Mr. Kapkanov, the man accused of being a cybercrime kingpin, was typical of the dysfunction that has plagued Ukraine.
“The whole situation is absurd, but nothing in my country really surprises me anymore,” he said, sitting in a park near the Poltava battle monument. “Ukraine is a country where anything is possible if you have money.”
It was to Ukraine that Mr. Manafort looked for new business horizons after doing work for despots in Africa and Asia. Setting up shop in Kiev, he became entangled in a murky constellation of Russian and Ukrainian business tycoons and politicians, notably Mr. Yanukovych, the president ousted in 2014.
Mr. Chornovil, who worked as Mr. Yanukovych’s campaign manager in 2004, remembers Mr. Manafort as “arrogant and full of self-confidence,” a showman who liked to organize big, splashy events that required lavish spending.
A secret ledger recording payments to Mr. Manafort and others, he said, was part of a crude effort to keep track of all the money sloshing through Mr. Yanukovych’s administration.
“Everyone was stealing, and the party wanted a record of who got what,” Mr. Chornovil. “They never imagined that they might lose power one day and the accounts would come to light.”
Mr. Manafort, he said, often clashed with members of the president’s entourage but “had a colossal influence on Yanukovych for some reason.”
He added: “He was not here out of any ideology but to make money. He was here exclusively for the money.”
The end of Mr. Yanukovych’s rule in 2014 upended Mr. Manafort’s business in Kiev and brought in Mr. Poroshenko on a wave of reformist fervor.
Left in place, however, was what has for years been Ukraine’s strength as a pluralistic society and also its fundamental flaw: a fragile state that is too fragmented by competing economic and regional interests to impose either Russian-style authoritarianism or European-style rule of law.
“There was never a strong state on this land. Medieval feudal mosaics, fragile kingdoms and early-modern Cossack republics had nothing in common with European absolutism or Russian authoritarianism,” said Valerii Pekar, a lecturer at the Kiev-Mohyla Business School, in a recent article. “This is a country of balance, not of leadership. Nobody can rule Ukraine like a king.”
The West, fed up with the dysfunction, has been pushing Mr. Poroshenko with only partial success to tip the balance away from the corruption-tainted oligarchs and Russian proxies who often held sway under Mr. Yanukovych.
He did establish an independent anti-corruption agency and introduce a mandatory declaration of assets for officials and members of Parliament. But he has so far stalled on setting up a tribunal outside the existing court system to try corruption cases.
Larissa Kulishova, the judge in Poltava who let the hacker go, denied that she had erred. In a brief interview, the judge said she had made her ruling “in full accordance with Ukrainian and European law.” She disputed an appeals court judgment issued after the hacker had fled that overturned her decision and said she had been wrong: “I don’t think I made a mistake.”
Larissa Golnyk, a judge in the same courthouse, said she could not speculate on what prompted her fellow judge to free Mr. Kapkanov but expressed dismay at the decision.
Ms. Golnyk has bitter experience of the pressures put on judges. Equipped with a secret camera by anti-corruption investigators, she filmed a representative of Poltava’s mayor offering her a $5,000 bribe to close a case. Posted online, the video produced a public uproar but no action against the mayor or his emissary.
“Every time something clearly wrong happens I ask, ‘How can this be happening?’” Ms. Golnyk said. “I am always told, ‘Come on, you must be used to such things by now.’”