Some liken his shadowy role — though not his ideas — to that of Mr. Trump’s former adviser Stephen K. Bannon, or Karl Rove, who counseled President George W. Bush.
But Mr. Wang moved from leader to leader, shaping the outlook not only of Mr. Xi but also his two predecessors, Hu Jintao and Jiang Zemin. In doing so, he has played a key role in justifying one-party rule during China’s transformation into a geopolitical rival of the United States.
“People call him the brain behind three supreme leaders,” said Yun Sun, a China expert at the Washington-based Stimson Center.
As a young professor in Shanghai in the late 1980s, Mr. Wang won attention for advocating “neo-authoritarianism,” the idea that a nation as big and poor as China needed a firm hand to push through modernization before it could consider becoming a democracy.
As others argued that China could never modernize without becoming democratic — a view that later gave rise to the ill-fated student movement based in Tiananmen Square — Mr. Wang made the case in a 1988 article that an enlightened autocracy would be “highly effective in distributing social resources” in order to “promote rapid economic growth.”
“He believed in modernization and that China needed strong political leadership,” said Ren Xiao, a professor of international relations at Fudan University in Shanghai and a former student of Mr. Wang. “That is still on his mind. It is his firm belief.”
In Mr. Xi, the most powerful Chinese leader in decades, Mr. Wang has found an ideological soul mate. Mr. Wang is believed to have helped craft Mr. Xi’s key slogans, including the one the party enshrined in its constitution last month, elevating Mr. Xi to the same status as Mao: “Xi Jinping Thought for the New Era of Socialism With Chinese Special Characteristics.”
Just as Mao made China independent and Deng Xiaoping made it prosperous, Mr. Xi has vowed to make China strong again. With Mr. Wang’s help, he has centralized power, tightened control of society and emphasized the need to keep a firm grip on the party itself using a sweeping anticorruption campaign.
To the outside world, their message is one of national pride: China has followed a different path to development from the United States, which it hopes to eclipse.
While many Chinese looked to the West for inspiration after the country opened up in the 1980s, Mr. Wang returned from two trips to the United States back then convinced that it was not a good model for China, according to his own writings and people who knew him.
“If pluralism means a multiparty system, Western-style elections — he doesn’t believe that kind of system is suitable for China,” Mr. Ren said.
Mr. Wang recorded the trips in a book called “America Against America.” In it, he offered a scathing description of the 1988 presidential contest between George H.W. Bush and Michael S. Dukakis. He also rejected the notion that America was a land of egalitarian opportunity where anyone could become president.
Born in the eastern province of Shandong, the birthplace of Confucius, Mr. Wang was a sickly teenager who, unlike many young people, was allowed to avoid heavy farm work during Mao’s destructive Cultural Revolution. He studied instead, learning French as his first foreign language.
Tutored by a prominent Marxist scholar, Chen Qiren, Mr. Wang gravitated toward the study of Western political thought. At 30, he became the youngest professor at Fudan University in Shanghai, and within just a few years had risen to head the law school.
“He taught Plato, Aristotle, the French Revolution, a little about the American Revolution, the Federalist Papers translated into Chinese,” Mr. Ren said.
As the coach of Fudan’s debate team, he would stand during practice with a plastic stick to make a show of driving his students to strive harder, though he never struck them, according to a collection of essays about the team’s trip to a 1988 competition in Singapore.
His team defeated National Taiwan University, 5-0, by out-debating it on the subject: Is human nature kind or evil? (Mr. Wang’s team argued for evil.)
Reflecting on the visit, Mr. Wang later wrote: “While Western modern civilization can bring material prosperity, it does not necessarily lead to improvement in character.”
As a member of delegations of young political scientists, he toured more than a dozen American campuses, including Harvard, the Massachusetts Institute of Technology and the University of Iowa.
“He was a very charismatic figure: young, articulate and adept at theoretical arguments,” said Miles Kahler, a senior fellow at the Council on Foreign Relations, who first encountered Mr. Wang in the early 1980s in Shanghai and later in California.
“He was definitely a skeptic of the wisdom of China moving toward a Western-style democracy,” Mr. Kahler added. “Wang Huning did not pretend to share such idolization of the United States.”
When the pro-democracy movement erupted on Tiananmen Square and spread to cities across the country in the spring of 1989, Mr. Wang kept his distance from the demonstrations in Shanghai.
In a letter written two months after the bloody crackdown that followed, he informed Mr. Kahler that one of his students had been “too active” in “recent affairs” to go to the United States but refrained from saying much more.
Soon afterward, Mr. Wang was recruited into politics by Jiang Zemin, the Shanghai party chief who became president of China after the crackdown. Mr. Jiang brought Mr. Wang to Beijing, where he stood out as a rare academic within a party leadership dominated by engineers and apparatchiks.
Mr. Wang’s first post was as head of the politics group inside the Central Policy Research Office, the party’s in-house think tank, which he was later promoted to lead.
When Mr. Jiang retired in 2002, Mr. Wang was promoted again, into the party’s influential Central Secretariat, the bureaucracy that serves the Politburo, even as he continued to run the research office.
After a decade serving Mr. Jiang’s successor, Mr. Wang transferred his allegiance to Mr. Xi, becoming a loyal adviser to the ambitious new president and a key member of his entourage on overseas trips.
He was there in 2013 when Mr. Xi visited Kazakhstan’s capital, Astana, to launch an effort to project Chinese power called the Belt and Road Initiative. Sitting in the audience, he approved photos of Mr. Xi for transmission by the state news agency, Xinhua.
Mr. Wang has returned several times to the United States with Mr. Xi and his predecessors. When he does, he has avoided his American peers, in keeping with the strict rules for senior party officials.
At a State Department lunch for Mr. Xi in 2015, Mr. Wang crossed paths with Kenneth G. Lieberthal, who had worked for President Bill Clinton on China issues at the National Security Council.
“When I asked whether I could see him during my next trip to Beijing, he indicated he now works ‘inside’ and thus would not be available,” Mr. Lieberthal said.