PRAGUE — After an election campaign centered on questions of civility in politics and the Czech Republic’s place in Europe, voters decided on Saturday to stick with President Milos Zeman and his often-caustic brand of populism that has stoked resentment toward Muslim immigrants and ruptured the country’s relationship with its allies to the west.
His opponent, Jiri Drahos, a political novice whose views were not well known, sought to present himself as an antidote to what he characterized as Mr. Zeman’s bitter and divisive leadership. In recent years, Mr. Zeman, 73, has strengthened the country’s ties with Russia and has courted China.
Mr. Drahos, 68, offered a firm commitment not just to the country’s membership in the European Union, but also to the bloc’s values. In rejecting his vision, the country was poised to continue in the same euroskeptic direction as its neighbors Hungary, Poland and Slovakia.
With more than 99 percent of the votes counted, the state-owned Czech News Agency declared Mr. Zeman the winner with 51.4 percent of the votes (or 2.8 million), compared with Mr. Drahos’s 48.6 percent (2.7 million).
“The Russians could not be happier,” said Michal Koran, an analyst at the Aspen Institute, a think tank based in Prague, and the founder of the Global Arena Research Institute, which uses economic data to help understand political trends.
“For all the talk of Russian meddling — and I believe they have meddled beyond a shadow of a doubt,” he added, “Europe is dividing itself, and they do not have to do much.”
Outside observers cited as an example of Russian interference a pernicious social media campaign against Mr. Drahos that accused him, with no evidence, of being a collaborator of the secret police during Communist rule.
But Mr. Koran noted that Mr. Zeman’s success was most likely fueled by deep divisions in Czech society and the president’s ability to tap into the anxiety of many Czechs who live outside prosperous cities.
Mr. Zeman, speaking to supporters at a hotel on the outskirts of Prague, said this would be his last campaign, vowing to abide by the constitutional term limits. He acknowledged how tight the race was, describing how his advisers had huddled nervously waiting for the numbers from Prague.
In the end, he was propelled to victory by a high turnout in the countryside. Over all, turnout was more than 66 percent.
“Five years ago, 2.7 million voters gave me their trust,” he said. “This time, it was 2.8 million.”
Mr. Zeman’s victory will most likely be viewed with concern by the country’s traditional allies like France and Germany, as well as leaders who are looking for greater integration among the European Union’s member nations.
“They will continue to have to deal with an unpredictable, grumpy populist; with an oligarch prime minister; and the support of the communists in Moscow,” Mr. Koran said.
Eliska Haskova Coolidge, a Zeman supporter and influential public figure, said that many fears of those in the West were overblown. She said she thought that Mr. Zeman’s goal was a healthy relationship with Russia, not a subservient one.
Ms. Coolidge, whose family fled the country after World War II, spent two decades working in Washington before returning home. She said she was no fan of Mr. Zeman’s vulgarity, but was willing to overlook some of his flaws because she admired the depth of his experience.
“It is so important to have a leader who understands politics and who has met with world leaders,” she said.
In the end, Czech voters agreed.
Mr. Drahos conceded the race and congratulated Mr. Zeman. “This is not the end,” Mr. Drahos told supporters gathered in Prague. “We will carry on.”
He then led members of the crowd, some in tears, in a solemn rendition of the national anthem.
Mr. Zeman’s re-election was also a victory for the country’s billionaire prime minister, Andrej Babis, who was appointed by Mr. Zeman and supported his campaign. The president has vowed to stick with him even though Mr. Babis is facing criminal fraud charges.
The election was not only a contest of competing visions for the country’s place in Europe and the world, but also a clash between two candidates with decidedly different styles.
Proudly antediluvian, with an admitted fondness for drinking and smoking, the acerbic Mr. Zeman has been criticized as contributing to the coarseness of the current political climate. His impolitic remarks — like jokes about “liquidating” journalists — have earned him comparisons to President Trump.
Mr. Drahos, the former leader of the Czech Academy of Sciences, has never held political office, and his inexperience was evident in the first of two debates. Looking nervous, he sat on the edge of his seat, while Mr. Zeman reclined and looked as if he were in his own living room, drink in hand.
In the second debate, Mr. Drahos was more confident and more direct in his attacks on the president.
“Mr. Zeman is the past,” he said. “He is now a symbol of division and name-calling.”
For many of Mr. Zeman’s supporters, however, his indecency is his strength, and they say his blunt speech is needed to counteract cowardly political blather.
Mr. Zeman was elected in 2013 in the first direct presidential vote held in the Czech Republic after it broke free from Soviet rule in 1989. Although he has a long history in politics and had served as prime minister, he cast himself as a populist savior working for the common man.
“You are not alone anymore,” was the Zeman slogan plastered on billboards and echoed in meeting after meeting in small towns and villages. His victory then was seen by many as a rebuke of the right-of-center political establishment that had grown smug and out of touch.
But as the migrant crisis in Europe blossomed in 2014, and countries confronted the greatest flood of humanity seeking refuge on the continent since the end of the Second World War, Mr. Zeman was one of the first European politicians to seize on the issue.
He sought to seal off the country and defied efforts by the European Union to force member nations to share the burden equally by taking in migrants through a quota system.
Mr. Zeman said Muslims could never be integrated in Czech society and warned of jihadists who could “blow the Prague castle up in the air,” tapping into an anxiety felt deeply throughout the country and the region. The message would soon be championed by a host of populist leaders, including those in neighboring countries.
But this Czech election campaign was notable for the lack of debate on immigration. The Zeman position was the default position. Still, Mr. Zeman sought to portray Mr. Drahos as a danger to society. “Stop migrants and Drahos,” read an ad in newspapers and on billboards. “This country is ours. Vote for Zeman.”
Mr. Drahos returned fire by attacking one of Mr. Zeman’s top advisers, Martin Nejedly, who is known for his close ties to Russia. “Stop Russian Invasion and Nejedly,” the Drahos team wrote in a social media campaign. “This country is not yours. Vote for Drahos.”
The question of whether the Czech Republic will continue to look to China and Russia was a critical issue in the last days of the campaign. While Mr. Zeman has often said he is committed to the European Union and NATO, he said during his victory speech that he would continue to support allowing Czechs to decide their own futures, including a referendum on membership in the bloc.
“I have come to the conclusion that many politicians and journalists have inferior intelligence compared to normal people,” Mr. Zeman said. “And, therefore, I want those normal citizens to have a chance to decide.”
He also said he would try and be more “humble” and less “arrogant,” but he used his speech to go over old grievances, including against Czech journalists who had repeatedly written him off.
“That’s another reason why I consider Czech journalists to be idiots,” he said.