The man accused of stabbing Lee Jae-myung, the leader of South Korea’s main opposition party, in the neck had been stalking him in recent weeks, including attending a political event where Mr. Lee was present on Dec. 13, apparently captured on video there wearing a blue paper crown, the police say.

At a rally on Tuesday, a man wearing a similar paper crown and carrying a message supporting Mr. Lee and his party was also carrying something else: a knife with a five-inch blade and a plastic handle wrapped with duct tape.

The attack, the worst against a South Korean politician in nearly two decades, seriously wounded Mr. Lee, who officials said was recovering in an intensive care unit at Seoul National University on Wednesday after surgery. And it deeply shocked a country that values hard-won years of relative peace after an era of political and military violence before establishing democracy in the 1990s.

The police said that the suspect, a 66-year-old real estate agent named Kim Jin-seong, had admitted an intent to kill Mr. Lee. Armed with a court-issued warrant, the police confiscated Mr. Kim’s mobile phone and raided his home and office in Asan, south of Seoul, on Wednesday, as they tried to piece together what might have motivated that attack.

With details still scarce, public debate and news editorials were expressing a growing concern about South Korea’s deepening political polarization and the hatred and extremism it has seemed to inspire, as well as the challenges it posed to the country’s young democracy.

“The opposition leader falls under a knife of ‘politics of hatred,’” read a headline from the Chosun Ilbo, the country’s leading conservative daily.

Officials said that little was known about Mr. Kim’s personal life or political and other background except that he was a former government official who had been operating a real estate agency in Asan since 2012. Police found no previous records of crime, drug use or psychiatric trouble, and said he was sober at the time of the attack on Mr. Lee. His neighbors said they had little interaction with him.

One neighbor remembered him as a kind and hard-working “gentleman” who kept his office open every day, even on weekends, but who didn’t speak with him about politics and lived alone in an apartment.

“He’s not someone who’d do such a thing,” said Park Min-joon, who runs a building management company. “I couldn’t believe it.”

The deep and bitter rivalry between Mr. Lee and President Yoon Suk Yeol has been center stage in South Korea’s political polarization since 2022, when Mr. Lee lost to Mr. Yoon with the thinnest margin of any free presidential election in South Korea. Instead of retiring from politics, as some presidential candidates have after defeats, Mr. Lee ran for — and won — a parliamentary seat, as well as chairmanship of the opposition Democratic Party.

Under Mr. Yoon, state prosecutors have launched a series of investigations against Mr. Lee and tried to arrest him on various corruption and other criminal charges. Mr. Yoon has also refused to grant Mr. Lee one-on-one meetings that South Korean presidents had often offered opposition leaders to seek political compromises. Instead, he has repeatedly characterized his political opponents as “anti-state forces” or “corrupt cartels.”

For his part, Mr. Lee accused Mr. Yoon of deploying state law-enforcement forces to intimidate his enemies. His party has refused to endorse many of Mr. Yoon’s appointees to the Cabinet and the Supreme Court. Political commentators likened the relationship between Mr. Yoon and Mr. Lee to “gladiators’ politics.”

“The two have been on a collision course for two years,” said Park Sung-min, head of MIN Consulting, a political consultancy. “President Yoon has been accused of not recognizing Lee Jae-myung as an opposition leader but rather as a criminal suspect. I don’t think his attitude will likely change following the knife attack against Lee.”

The last major attack on a domestic political leader happened in 2006, when Park Geun-hye, then an opposition leader, was slashed in the face with a box cutter. But the attack was seen largely as an isolated outburst of anger by an ex-convict who complained of mistreatment by the law enforcement system. (Ms. Park went on to win the 2012 presidential election.)

But in recent years, politicians have been increasingly exposed to hatred in the public sphere, as political polarization deepened. In a survey sponsored by the newspaper Hankyoreh in December, more than 50 percent of respondents said they felt the political divide worsening. In another survey in December, commissioned by the Chosun Ilbo, four out of every 10 respondents said they found it uncomfortable to share meals or drinks with people who didn’t share their political views.

South Koreans had an early inkling of the current problem. During the presidential election campaign in 2022, Song Young-gil, an opposition leader, was attacked by a bludgeon-wielding man in his 70s, who subsequently killed himself in jail.

Jin Jeong-hwa, a YouTuber whose channel openly supports Mr. Lee and who live-streamed the knife attack on Tuesday, said he could feel the increasing political tension and hatred everyday. Once, when he visited a conservative town in central South Korea, people who recognized him tried to chase him out, threatening him with knives and sickles.

“You see a lot of anger, vilification, character assassination and demonizing,” Mr. Jin said. “I am not sure whether rational debate on issues and ideologies is possible anymore.”

On Wednesday, Mr. Yoon wished Mr. Lee a quick recovery, calling attacks against politicians “an enemy of free democracy.” His government ordered beefed-up public security for politicians.

But analysts saw little chance of political polarization easing anytime soon as the rival parties geared up for parliamentary elections in April. Social media, especially YouTube, has become so influential as a channel of spreading news and shaping public opinion that politicians said they found themselves beholden to populist demands from activist YouTubers who were widely accused of stoking fear and hatred.

Both Mr. Yoon and Mr. Lee have fervent online supporters who often resort to whipping up insults, conspiracy theories and even thinly veiled death threats against their foes.

“Hate has become a daily norm” in South Korean politics, said Mr. Park, the head of MIN Consulting. “Politicians must face the reality that similar things can happen again,” he said, referring to the knife attack against Mr. Lee.