But the realities in Europe were changing by the time he won the Czech presidency in 2013.

The global financial crisis had tested Europe’s unity. Refugees from Syria had begun to arrive, fueling nativist sentiment and pitting local politicians against the bloc’s leaders. Western Europe no longer seemed to be the only option.

At the time, Beijing was beginning to pour money and political capital into Eastern and Central Europe as part of a broad bid to increase its heft in Europe. China’s leaders see the region as potentially fertile ground. While Britain, France and Germany welcomed greater investments from Beijing, they still bucked China’s stances on issues like human rights and its claim to control almost all of the South China Sea. Eastern and Central Europe didn’t have the same qualms.

Looking for further inroads, China started what came to be called the 16+1 initiative, an effort to expand cooperation with more than a dozen Eastern and Central European nations. It became a forum for China to show off what it could offer the region, like access to technology for a high-speed rail system. Mr. Xi later included Eastern and Central Europe in his Belt and Road Initiative, an ambitious plan to develop economic and diplomatic ties through infrastructure projects around the world.

China’s influence in Europe is already apparent. Greece last year blocked a European Union statement in the United Nations criticizing China’s human rights record. Greece and Hungary worked to water down a 2016 European Union statement regarding the South China Sea.

For Mr. Zeman, the courtship basically had to start from scratch.

The former Czechoslovakia recognized the Communist-led China in 1949, but a rift between Moscow and Beijing kept them apart. The post-Soviet Czech Republic, remembering the brutal 1968 Soviet crackdown on reform efforts in Prague and subsequent Communist domination, found common cause with Beijing’s critics.

Vaclav Havel, the anti-Communist activist and the country’s first leader after the fall of the Berlin Wall, invited the Dalai Lama to a state visit in 1990, angering Beijing. He had stern words for China. “Intimidation, propaganda campaigns, and repression,” he wrote, “are no substitute for reasoned dialogue.”