When President Xi Jinping of China made his first state visit to the United States in 2015, he wrapped his demands for respect in reassurances.

He courted tech executives, while defending China’s internet controls. He denied that China was militarizing the disputed South China Sea, while asserting its maritime claims there. He spoke hopefully of a “new model” for great power relations, in which Beijing and Washington would coexist peacefully as equals.

But back in China, in meetings with the military, Mr. Xi was warning in strikingly stark terms that intensifying competition between a rising China and a long-dominant United States was all but unavoidable, and that the People’s Liberation Army should be prepared for a potential conflict.

In Mr. Xi’s telling, China sought to rise peacefully, but Western powers would not accept the idea that a Communist-led China was catching up and could someday overtake them in global primacy. The West would never stop trying to derail China’s ascent and topple its Communist Party, he said in speeches to the military that are largely unreported by the media.

“Beyond doubt, our country’s growing strength is the most important factor driving a profound readjustment of the international order,” he told top commanders in November 2015, two months after his visit to the United States. “Some Western countries absolutely never want to see a socialist China grow strong under the leadership of the Chinese Communist Party.”

Despite his assurances to President Obama not to militarize the South China Sea, Mr. Xi told his senior commanders in February 2016 that China must bolster its presence there, saying: “We’ve seized the opportunity, eliminated intervention and sped up construction on South China Sea islands and shoals, achieving a historic breakthrough in maritime strategy and defending maritime rights.” (In the years that followed, China quickly expanded its military infrastructure in the area.)

Mr. Xi’s remarks are among collections of speeches that Mr. Xi made to the People’s Liberation Army and Communist Party officials, published by the military for internal study by senior officers, and seen and corroborated by The New York Times. The volumes, “Xi Jinping’s Selected Major Statements on National Defense and Military Development,” cover his initial years in power, from 2012 to February 2016.

The speeches offer a new, unvarnished view into the leader at the center of a superpower rivalry that is shaping the 21st century. They show how at times he has voiced an almost fatalistic conviction — even before Beijing’s ties with Washington took a steep dive later in the Trump administration — that China’s rise would prompt a backlash from Western rivals seeking to maintain their dominance.

“The faster we develop, the bigger the external shock will be, and the greater the strategic blowback,” Mr. Xi told Chinese Air Force officers in 2014.

In Mr. Xi’s worldview, the West has sought to subvert the Chinese Communist Party’s power at home and contain the country’s influence abroad. The Communist Party had to respond to these threats with iron-fisted rule and an ever-stronger People’s Liberation Army.

As Mr. Xi prepares to meet with President Biden in California this week, the question of how the two powers will manage their rivalry hangs over the relationship.

Mr. Xi has been trying to stabilize relations with Washington, apparently pressed by China’s economic troubles and a desire to reduce Beijing’s diplomatic isolation. “We have a thousand reasons to grow the relationship between China and the United States, and none at all to ruin it,” Mr. Xi told American lawmakers in Beijing recently.

But with mutual distrust running deep, any easing of antagonism between the two sides could be tenuous.

Mr. Xi underscored that his judgment of the challenge posed by the United States remains unchanged, saying with rare public bluntness in March: “Western countries led by the United States have implemented all-around containment, encirclement and suppression of China.”

Mr. Xi’s views of the world and the United States bear the imprint of China’s turbulent years when he was preparing to assume power. China had grown quickly, but the reforms that boosted that growth had slowed, and official corruption was rampant. The security state had expanded, but so had protest and dissent.

As Mr. Xi emerged as the country’s leader-in-waiting in 2007, some diplomats, experts and well-connected Communist Party veterans predicted that he would be a pragmatist who might restart China’s efforts toward economic liberalization. Some even saw in him a chance for political change after a long period of stagnation.

They cited Mr. Xi’s pedigree as the son of a revolutionary leader who had helped oversee China’s economic overhaul in the 1980s and the decades Mr. Xi had spent as an official in the commercial coastal provinces of eastern China, including 17 years in Fujian, where he courted investors from neighboring Taiwan. Li Rui, a retired senior official who had once served as Mao Zedong’s aide, recorded in his diary a conversation in 2007 about the relatively unknown Mr. Xi.

“I asked what Xi Jinping was like, and the answer was four words: ‘governing by doing nothing,’” Mr. Li wrote. “That would be good,” Mr. Li added, “letting everyone play to their strengths with less meddling.” (Mr. Li died in 2019; his diaries and correspondences are held by the Hoover Institution at Stanford University.)

But Mr. Xi’s upbringing and family background left a more complex imprint than many assumed: He was, above all, proud of the party and the Communist revolution. And skepticism about American might and wariness about its intentions toward China were becoming more mainstream in Beijing as Mr. Xi prepared to take the reins of power.

The global financial crisis of 2007-08 had shattered official Chinese assumptions that Washington’s economic policymakers were competent, even if Beijing disagreed with them. Chinese officials quizzed American officials like Hank Paulson, then the Treasury secretary, about their mishandling of the situation. For many in Beijing, the lessons extended beyond the financial system.

“It was a defining moment,” said Desmond Shum, a businessman whose memoir, Red Roulette, describes those years, when he mingled with China’s political elite. “After that point, the entire Western model was questioned much more. There was also this growing belief that the world would need China to lead the way out of the mess.”

As Mr. Xi prepared to become China’s leader, President Vladimir V. Putin of Russia was emerging as a model of an authoritarian strongman pushing back against American pre-eminence.

“These two men have a shared mental map of the world — not perfectly the same, but shared,” said Jude Blanchette, a China expert at the Center for Strategic and International Studies. “Both want to return their countries to a lost inheritance of greatness; both want to reclaim key territories; both have a shared sense of the trauma of the collapse of the Soviet Union.”

In particular, Mr. Xi and Mr. Putin, who met in 2010, shared a suspicion that the United States was bent on destabilizing its rivals by instigating insurrection in the name of democracy. Mr. Xi and other Chinese leaders adopted Mr. Putin’s conception of “color revolutions” to describe such unrest.

In the mid-2000s, official Chinese fears of an eruption of anti-party protests did not seem so far-fetched. Flagrant corruption and official scandals had incensed many people. The internet opened up new channels for amplifying grievances.

Chinese Communist Party leaders have long sought to mobilize support by citing a miasma of external threats. Warnings of an American conspiracy to overthrow the party and transform China into a capitalist country by “peaceful evolution” go back to the Mao era. But Mr. Xi has evoked those warnings with distinct urgency.

“He’s somebody who spent years of his life lacking security and, as he said later, learning from his father about the fickleness of human relationships and power,” said Joseph Torigian, a research fellow at the Hoover History Lab at Stanford University who has examined Mr. Xi’s speeches to the military. “Now he becomes the named successor, and he’s looking around the world and seeing ‘color revolutions’ and United States meddling and, for him, it’s this idea that, ultimately, power is the last guarantor of security and strength.”

Mr. Xi saw lessons in the “Arab Spring” uprisings that had toppled corrupt authoritarian leaders across the Middle East. The overthrow of Egypt’s leader, Hosni Mubarak, in 2011, left a deep impression on Chinese leaders, who saw parallels with the 1989 pro-democracy protests at Tiananmen Square in Beijing, said John K. Culver, a former Central Intelligence Agency officer who followed Mr. Xi’s rise.

“What really scared them was Egypt, because Hosni Mubarak rose as an officer in the Egyptian military, and yet the military turned on him,” Mr. Culver said. Chinese leaders, he added, “saw that and asked themselves: ‘If Tiananmen Square happened today, would the army again save the party?’”

Within weeks of taking power in late 2012, Mr. Xi met with officials and sounded a warning: The collapse of the Soviet Union, he said, was a cautionary tale for China. It had fallen, he lamented, because its military had lost its nerve. He warned officials that China could suffer the same fate unless the party recovered its ideological backbone.

Months later, he issued an internal edict to roll back the influence of what he called Western ideas, such as the concept of universal human rights and the rule of law, in universities and the news media.

From his first presidential summit with Mr. Obama in 2013, Mr. Xi had shown himself to be a “much more assertive and confident leader” than his predecessor, Hu Jintao, setting aside his talking points to press his views, according to Ben Rhodes, a former deputy national security adviser to Mr. Obama.

“This was a guy who was not just the frontman of a party, he was his own man,” Mr. Rhodes said in an email.

Mr. Xi, who leads the military as chairman of the Central Military Commission, reserved some of his bluntest warnings about the West for his commanders.

“The ‘laws of the jungle’ of international competition have not changed,” he told military delegates to China’s national legislature in 2014. He pointed to the growing presence of American jets, ships and aircraft carriers in the Asia-Pacific region as evidence that the United States was seeking to contain China.

He also said that the pro-Western protests that were then sweeping across Ukraine were a warning for Beijing. “Some Western countries are fanning the flames there and secretly scheming to achieve their geopolitical goals there,” he said. “We must take heed of this lesson.”

To prepare for the threats Mr. Xi saw ahead, he said, China needed to urgently overhaul its military. From late 2015, he initiated a sweeping reorganization of the People’s Liberation Army, seeking to make it an integrated force capable of extending Chinese power abroad, especially through air, sea and space forces. His warnings about the West helped underscore the urgency of those changes.

“Speeches to people within the system are attempts to mobilize,” said Mr. Blanchette, the researcher in Washington. “You don’t do that by just saying that the world is getting a little bit complicated; you need a narrative that is going to allow you to smash vested interests to achieve change.”

Mr. Xi warned that the People’s Liberation Army was still dangerously backward, and could fall behind if it did not seek to innovate, particularly in upgrading its weaponry and command organization. In these speeches, Mr. Xi did not say that war was unavoidable. But he made clear that without a formidable military, China would not be able to assert its will.

“In international contestation, political operations are very important, but ultimately it comes down to whether you have strength and whether you can use that strength,” he told the commanders on the Central Military Commission in November 2015. “Relying on a silver tongue won’t work.”

Amy Chang Chien contributed reporting in Taipei.