They didn’t like the West’s playbook. So they wrote their own.

The pull of the past: Aerospace workers wearing Long March-style uniforms. Bryan Denton for The New York Times

The West was sure the Chinese approach would not work. It just had to wait. It’s still waiting.

In the uncertain years after Mao’s death, long before China became an industrial juggernaut, before the Communist Party went on a winning streak that would reshape the world, a group of economics students gathered at a mountain retreat outside Shanghai. There, in the bamboo forests of Moganshan, the young scholars grappled with a pressing question: How could China catch up with the West?

It was the autumn of 1984, and on the other side of the world, Ronald Reagan was promising “morning again in America.” China, meanwhile, was just recovering from decades of political and economic turmoil. There had been progress in the countryside, but more than three-quarters of the population still lived in extreme poverty. The state decided where everyone worked, what every factory made and how much everything cost.

The students and researchers attending the Academic Symposium of Middle-Aged and Young Economists wanted to unleash market forces but worried about crashing the economy — and alarming the party bureaucrats and ideologues who controlled it.

Late one night, they reached a consensus: Factories should meet state quotas but sell anything extra they made at any price they chose. It was a clever, quietly radical proposal to undercut the planned economy — and it intrigued a young party official in the room who had no background in economics. “As they were discussing the problem, I didn’t say anything at all,” recalled Xu Jing’an, now 76 and retired. “I was thinking, how do we make this work?”

How China became a superpower

The Chinese economy has grown so fast for so long now that it is easy to forget how unlikely its metamorphosis into a global powerhouse was, how much of its ascent was improvised and born of desperation. The proposal that Mr. Xu took from the mountain retreat, soon adopted as government policy, was a pivotal early step in this astounding transformation.

China now leads the world in the number of homeowners, internet users, college graduates and, by some counts, billionaires. Extreme poverty has fallen to less than 1 percent. An isolated, impoverished backwater has evolved into the most significant rival to the United States since the fall of the Soviet Union.

China today might be unrecognizable to its Communist founders, but the past still holds a powerful allure. “Red tourism” is a big industry. Bryan Denton for The New York Times It is less worried now about catching up to the West. Instead, it wonders how to pull ahead. Bryan Denton for The New York Times The country leads the world in the number of internet users and college graduates. It is now working to land a person on the moon. Bryan Denton for The New York Times Gone are the days when the state decided where everyone worked and what every factory made. Bryan Denton for The New York Times The world thought it would change China, but China’s success has been so spectacular that it has changed the world. Bryan Denton for The New York Times

An epochal contest is underway. With President Xi Jinping pushing a more assertive agenda overseas and tightening controls at home, the Trump administration has launched a trade war and is gearing up for what could be a new Cold War. Meanwhile, in Beijing the question these days is less how to catch up with the West than how to pull ahead — and how to do so in a new era of American hostility.

The pattern is familiar to historians, a rising power challenging an established one, with a familiar complication: For decades, the United States encouraged and aided China’s rise, working with its leaders and its people to build the most important economic partnership in the world, one that has lifted both nations.

During this time, eight American presidents assumed, or hoped, that China would eventually bend to what were considered the established rules of modernization: Prosperity would fuel popular demands for political freedom and bring China into the fold of democratic nations. Or the Chinese economy would falter under the weight of authoritarian rule and bureaucratic rot.

But neither happened. Instead, China’s Communist leaders have defied expectations again and again. They embraced capitalism even as they continued to call themselves Marxists. They used repression to maintain power but without stifling entrepreneurship or innovation. Surrounded by foes and rivals, they avoided war, with one brief exception, even as they fanned nationalist sentiment at home. And they presided over 40 years of uninterrupted growth, often with unorthodox policies the textbooks said would fail.

In late September, the People’s Republic of China marked a milestone, surpassing the Soviet Union in longevity. Days later, it celebrated a record 69 years of Communist rule. And China may be just hitting its stride — a new superpower with an economy on track to become not just the world’s largest but, quite soon, the largest by a wide margin.

The world thought it could change China, and in many ways it has. But China’s success has been so spectacular that it has just as often changed the world — and the American understanding of how the world works.

There is no simple explanation for how China’s leaders pulled this off. There was foresight and luck, skill and violent resolve, but perhaps most important was the fear — a sense of crisis among Mao’s successors that they never shook, and that intensified after the Tiananmen Square massacre and the collapse of the Soviet Union.

Even as they put the disasters of Mao’s rule behind them, China’s Communists studied and obsessed over the fate of their old ideological allies in Moscow, determined to learn from their mistakes. They drew two lessons: The party needed to embrace “reform” to survive — but “reform” must never include democratization.

China has veered between these competing impulses ever since, between opening up and clamping down, between experimenting with change and resisting it, always pulling back before going too far in either direction for fear of running aground.

Many people said that the party would fail, that this tension between openness and repression would be too much for a nation as big as China to sustain. But it may be precisely why China soared.

Whether it can continue to do so with the United States trying to stop it is another question entirely.

Apparatchiks Into Capitalists

None of the participants at the Moganshan conference could have predicted how China would take off, much less the roles they would play in the boom ahead. They had come of age in an era of tumult, almost entirely isolated from the rest of the world, with little to prepare them for the challenge they faced. To succeed, the party had to both reinvent its ideology and reprogram its best and brightest to carry it out.

Mr. Xu, for example, had graduated with a degree in journalism on the eve of Mao’s violent Cultural Revolution, during which millions of people were purged, persecuted and killed. He spent those years at a “cadre school” doing manual labor and teaching Marxism in an army unit. After Mao’s death, he was assigned to a state research institute tasked with fixing the economy. His first job was figuring out how to give factories more power to make decisions, a subject he knew almost nothing about. Yet he went on to a distinguished career as an economic policymaker, helping launch China’s first stock market in Shenzhen.

Among the other young participants in Moganshan were Zhou Xiaochuan, who would later lead China’s central bank for 15 years; Lou Jiwei, who ran China’s sovereign wealth fund and recently stepped down as finance minister; and an agricultural policy specialist named Wang Qishan, who rose higher than any of them.

Mr. Wang headed China’s first investment bank and helped steer the nation through the Asian financial crisis. As Beijing’s mayor, he hosted the 2008 Olympics. Then he oversaw the party’s recent high-stakes crackdown on corruption. Now he is China’s vice president, second in authority only to Xi Jinping, the party’s leader.

The careers of these men from Moganshan highlight an important aspect of China’s success: It turned its apparatchiks into capitalists.

Bureaucrats who were once obstacles to growth became engines of growth. Officials devoted to class warfare and price controls began chasing investment and promoting private enterprise. Every day now, the leader of a Chinese district, city or province makes a pitch like the one Yan Chaojun made at a business forum in September.

“Sanya,” Mr. Yan said, referring to the southern resort town he leads, “must be a good butler, nanny, driver and cleaning person for businesses, and welcome investment from foreign companies.”

It was a remarkable act of reinvention, one that eluded the Soviets. In both China and the Soviet Union, vast Stalinist bureaucracies had smothered economic growth, with officials who wielded unchecked power resisting change that threatened their privileges.

Mikhail Gorbachev, the last leader of the Soviet Union, tried to break the hold of these bureaucrats on the economy by opening up the political system. Decades later, Chinese officials still take classes on why that was a mistake. The party even produced a documentary series on the subject in 2006, distributing it on classified DVDs for officials at all levels to watch.

Afraid to open up politically but unwilling to stand still, the party found another way. It moved gradually and followed the pattern of the compromise at Moganshan, which left the planned economy intact while allowing a market economy to flourish and outgrow it.

Once an impoverished backwater, China is now the most significant rival to the United States. Wuhan, a former river town, has swelled into a metropolis of over 10 million. Bryan Denton for The New York Times A businessman stretched before a round of video golf at a hotel he built in Kunming. Bryan Denton for The New York Times Rising incomes have turned China into a nation of consumers. Bryan Denton for The New York Times In cities like Shanghai, Chinese schoolchildren outperform peers around the world. Bryan Denton for The New York Times Western economists doubted that innovation could take place under China’s rigid bureaucracy. They were proved wrong. Bryan Denton for The New York Times

Party leaders called this go-slow, experimental approach “crossing the river by feeling the stones” — allowing farmers to grow and sell their own crops, for example, while retaining state ownership of the land; lifting investment restrictions in “special economic zones,” while leaving them in place in the rest of the country; or introducing privatization by selling only minority stakes in state firms at first.

“There was resistance,” Mr. Xu said. “Satisfying the reformers and the opposition was an art.”

American economists were skeptical. Market forces needed to be introduced quickly, they argued; otherwise, the bureaucracy would mobilize to block necessary changes. After a visit to China in 1988, the Nobel laureate Milton Friedman called the party’s strategy “an open invitation to corruption and inefficiency.”

But China had a strange advantage in battling bureaucratic resistance. The nation’s long economic boom followed one of the darkest chapters of its history, the Cultural Revolution, which decimated the party apparatus and left it in shambles. In effect, autocratic excess set the stage for Mao’s eventual successor, Deng Xiaoping, to lead the party in a radically more open direction.

That included sending generations of young party officials to the United States and elsewhere to study how modern economies worked. Sometimes they enrolled in universities, sometimes they found jobs, and sometimes they went on brief “study tours.” When they returned, the party promoted their careers and arranged for others to learn from them.

At the same time, the party invested in education, expanding access to schools and universities, and all but eliminating illiteracy. Many critics focus on the weaknesses of the Chinese system — the emphasis on tests and memorization, the political constraints, the discrimination against rural students. But mainland China now produces more graduates in science and engineering every year than the United States, Japan, South Korea and Taiwan combined.

In cities like Shanghai, Chinese schoolchildren outperform peers around the world. For many parents, though, even that is not enough. Because of new wealth, a traditional emphasis on education as a path to social mobility and the state’s hypercompetitive college entrance exam, most students also enroll in after-school tutoring programs — a market worth $125 billion, according to one study, or as much as half the government’s annual military budget.

Another explanation for the party’s transformation lies in bureaucratic mechanics. Analysts sometimes say that China embraced economic reform while resisting political reform. But in reality, the party made changes after Mao’s death that fell short of free elections or independent courts yet were nevertheless significant.

The party introduced term limits and mandatory retirement ages, for example, making it easier to flush out incompetent officials. And it revamped the internal report cards it used to evaluate local leaders for promotions and bonuses, focusing them almost exclusively on concrete economic targets.

These seemingly minor adjustments had an outsize impact, injecting a dose of accountability — and competition — into the political system, said Yuen Yuen Ang, a political scientist at the University of Michigan. “China created a unique hybrid,” she said, “an autocracy with democratic characteristics.”

As the economy flourished, officials with a single-minded focus on growth often ignored widespread pollution, violations of labor standards, and tainted food and medical supplies. They were rewarded with soaring tax revenues and opportunities to enrich their friends, their relatives and themselves. A wave of officials abandoned the state and went into business. Over time, the party elite amassed great wealth, which cemented its support for the privatization of much of the economy it once controlled.

The private sector now produces more than 60 percent of the nation’s economic output, employs over 80 percent of workers in cities and towns, and generates 90 percent of new jobs, a senior official said in a speech last year. As often as not, the bureaucrats stay out of the way.

“I basically don’t see them even once a year,” said James Ni, chairman and founder of Mlily, a mattress manufacturer in eastern China. “I’m creating jobs, generating tax revenue. Why should they bother me?”

In recent years, President Xi has sought to assert the party’s authority inside private firms. He has also bolstered state-owned enterprises with subsidies while preserving barriers to foreign competition. And he has endorsed demands that American companies surrender technology in exchange for market access.

In doing so, he is betting that the Chinese state has changed so much that it should play a leading role in the economy — that it can build and run “national champions” capable of outcompeting the United States for control of the high-tech industries of the future. But he has also provoked a backlash in Washington.

‘Opening Up’

In December, the Communist Party will celebrate the 40th anniversary of the “reform and opening up” policies that transformed China. The triumphant propaganda has already begun, with Mr. Xi putting himself front and center, as if taking a victory lap for the nation.

He is the party’s most powerful leader since Deng and the son of a senior official who served Deng, but even as he wraps himself in Deng’s legacy, Mr. Xi has set himself apart in an important way: Deng encouraged the party to seek help and expertise overseas, but Mr. Xi preaches self-reliance and warns of the threats posed by “hostile foreign forces.”

In other words, he appears to have less use for the “opening up” part of Deng’s slogan.

Of the many risks that the party took in its pursuit of growth, perhaps the biggest was letting in foreign investment, trade and ideas. It was an exceptional gamble by a country once as isolated as North Korea is today, and it paid off in an exceptional way: China tapped into a wave of globalization sweeping the world and emerged as the world’s factory. China’s embrace of the internet, within limits, helped make it a leader in technology. And foreign advice helped China reshape its banks, build a legal system and create modern corporations.

The party prefers a different narrative these days, presenting the economic boom as “grown out of the soil of China” and primarily the result of its leadership. But this obscures one of the great ironies of China’s rise — that Beijing’s former enemies helped make it possible.

President Xi Jinping has shown no sign of abandoning what he calls “the great rejuvenation of the Chinese nation.” The observation deck of the Shanghai Tower, the world’s second-tallest building. Bryan Denton for The New York Times A Communist Party Congress. Mr. Xi seems to believe that China has been so successful that the party can return to its authoritarian past. Bryan Denton for The New York Times China tapped into a wave of globalization and emerged as the world’s factory. Advertising for day laborers in Shenzhen. Bryan Denton for The New York Times A fashion design employee at a bridal wear exhibition in Beijing may have taken the opportunity for a break, but no one calls China a sleeping giant anymore. Bryan Denton for The New York Times Installing solar panels on a 47-story residential development. China succeeded by leaving a planned economy intact and allowing a market economy to flourish and outgrow it. Bryan Denton for The New York Times

The United States and Japan, both routinely vilified by party propagandists, became major trading partners and were important sources of aid, investment and expertise. The real game changers, though, were people like Tony Lin, a factory manager who made his first trip to the mainland in 1988.

Mr. Lin was born and raised in Taiwan, the self-governing island where those who lost the Chinese civil war fled after the Communist Revolution. As a schoolboy, he was taught that mainland China was the enemy.

But in the late 1980s, the sneaker factory he managed in central Taiwan was having trouble finding workers, and its biggest customer, Nike, suggested moving some production to China. Mr. Lin set aside his fears and made the trip. What he found surprised him: a large and willing work force, and officials so eager for capital and know-how that they offered the use of a state factory free and a five-year break on taxes.

Mr. Lin spent the next decade shuttling to and from southern China, spending months at a time there and returning home only for short breaks to see his wife and children. He built and ran five sneaker factories, including Nike’s largest Chinese supplier.

“China’s policies were tremendous,” he recalled. “They were like a sponge absorbing water, money, technology, everything.”

Mr. Lin was part of a torrent of investment from ethnic Chinese enclaves in Hong Kong, Taiwan, Singapore and beyond that washed over China — and gave it a leg up on other developing countries. Without this diaspora, some economists argue, the mainland’s transformation might have stalled at the level of a country like Indonesia or Mexico.

The timing worked out for China, which opened up just as Taiwan was outgrowing its place in the global manufacturing chain. China benefited from Taiwan’s money, but also its managerial experience, technology and relationships with customers around the world. In effect, Taiwan jump-started capitalism in China and plugged it into the global economy.

Before long, the government in Taiwan began to worry about relying so much on its onetime enemy and tried to shift investment elsewhere. But the mainland was too cheap, too close and, with a common language and heritage, too familiar. Mr. Lin tried opening factories in Thailand, Vietnam and Indonesia but always came back to China.

Now Taiwan finds itself increasingly dependent on a much more powerful China, which is pushing ever harder for unification, and the island’s future is uncertain.

There are echoes of Taiwan’s predicament around the world, where many are having second thoughts about how they rushed to embrace Beijing with trade and investment.

The remorse may be strongest in the United States, which brought China into the World Trade Organization, became China’s largest customer and now accuses it of large-scale theft of technology — what one official called “the greatest transfer of wealth in history.”

Many in Washington predicted that trade would bring political change. It did, but not in China. “Opening up” ended up strengthening the party’s hold on power rather than weakening it. The shock of China’s rise as an export colossus, however, was felt in factory towns around the world.

In the United States, economists say at least two million jobs disappeared as a result, many in districts that ended up voting for President Trump.

Selective Repression

Over lunch at a luxurious private club on the 50th floor of an apartment tower in central Beijing, one of China’s most successful real estate tycoons explained why he had left his job at a government research center after the crackdown on the student-led democracy movement in Tiananmen Square.

“It was very easy,” said Feng Lun, the chairman of Vantone Holdings, which manages a multibillion-dollar portfolio of properties around the world. “One day, I woke up and everyone had run away. So I ran, too.”

Until the soldiers opened fire, he said, he had planned to spend his entire career in the civil service. Instead, as the party was pushing out those who had sympathized with the students, he joined the exodus of officials who started over as entrepreneurs in the 1990s.

“At the time, if you held a meeting and told us to go into business, we wouldn’t have gone,” he recalled. “So this incident, it unintentionally planted seeds in the market economy.”

Such has been the seesaw pattern of the party’s success.

The pro-democracy movement in 1989 was the closest the party ever came to political liberalization after Mao’s death, and the crackdown that followed was the furthest it went in the other direction, toward repression and control. After the massacre, the economy stalled and retrenchment seemed certain. Yet three years later, Deng used a tour of southern China to wrestle the party back to “reform and opening up” once more.

Many who had left the government, like Mr. Feng, suddenly found themselves leading the nation’s transformation from the outside, as its first generation of private entrepreneurs.

Now Mr. Xi is steering the party toward repression again, tightening its grip on society, concentrating power in his own hands and setting himself up to rule for life by abolishing the presidential term limit. Will the party loosen up again, as it did a few years after Tiananmen, or is this a more permanent shift? If it is, what will it mean for the Chinese economic miracle?

The fear is that Mr. Xi is attempting to rewrite the recipe behind China’s rise, replacing selective repression with something more severe.

For decades, China has veered between openness and repression, including of the ethnic Uighur minority. Bryan Denton for The New York Times Since the Tiananmen movement, the government has been vigilant about crushing potential threats. Surveillance cameras in Beijing. Bryan Denton for The New York Times China’s high-speed rail network, the largest in the world, has changed the way its people move. In Hangzhou, passengers waited outside the railway station. Bryan Denton for The New York Times As China opened up, farmers were allowed to grow and sell their own crops, while the state retained ownership of the land. Greenhouses filled with bok choy and yellow cabbage abut investment properties and golf courses. Under Mao, many educated Chinese were sent to “cadre schools,” where they did manual labor. In May, these real estate agency employees went for a morning run as part of a company team-building exercise. Bryan Denton for The New York Times

The party has always been vigilant about crushing potential threats — a fledgling opposition party, a popular spiritual movement, even a dissident writer awarded the Nobel Peace Prize. But with some big exceptions, it has also generally retreated from people’s personal lives and given them enough freedom to keep the economy growing.

The internet is an example of how it has benefited by striking a balance. The party let the nation go online with barely an inkling of what that might mean, then reaped the economic benefits while controlling the spread of information that could hurt it.

In 2011, it confronted a crisis. After a high-speed train crash in eastern China, more than 30 million messages criticizing the party’s handling of the fatal accident flooded social media — faster than censors could screen them.

Panicked officials considered shutting down the most popular service, Weibo, the Chinese equivalent of Twitter, but the authorities were afraid of how the public would respond. In the end, they let Weibo stay open but invested much more in tightening controls and ordered companies to do the same.

The compromise worked. Now, many companies assign hundreds of employees to censorship duties — and China has become a giant on the global internet landscape.

“The cost of censorship is quite limited compared to the great value created by the internet,” said Chen Tong, an industry pioneer. “We still get the information we need for economic progress.”

A ‘New Era’

China is not the only country that has squared the demands of authoritarian rule with the needs of free markets. But it has done so for longer, at greater scale and with more convincing results than any other.

The question now is whether it can sustain this model with the United States as an adversary rather than a partner.

The trade war has only just begun. And it is not just a trade war. American warships and planes are challenging Chinese claims to disputed waters with increasing frequency even as China keeps ratcheting up military spending. And Washington is maneuvering to counter Beijing’s growing influence around the world, warning that a Chinese spending spree on global infrastructure comes with strings attached.

The two nations may yet reach some accommodation. But both left and right in America have portrayed China as the champion of an alternative global order, one that embraces autocratic values and undermines fair competition. It is a rare consensus for the United States, which is deeply divided about so much else, including how it has wielded power abroad in recent decades — and how it should do so now.

Mr. Xi, on the other hand, has shown no sign of abandoning what he calls “the great rejuvenation of the Chinese nation.” Some in his corner have been itching to take on the United States since the 2008 financial crisis and see the Trump administration’s policies as proof of what they have always suspected — that America is determined to keep China down.

At the same time, there is also widespread anxiety over the new acrimony, because the United States has long inspired admiration and envy in China, and because of a gnawing sense that the party’s formula for success may be faltering.

Prosperity has brought rising expectations in China; the public wants more than just economic growth. It wants cleaner air, safer food and medicine, better health care and schools, less corruption and greater equality. The party is struggling to deliver, and tweaks to the report cards it uses to measure the performance of officials hardly seem enough.

“The basic problem is, who is growth for?” said Mr. Xu, the retired official who wrote the Moganshan report. “We haven’t solved this problem.”

Growth has begun to slow, which may be better for the economy in the long term but could shake public confidence. The party is investing ever more in censorship to control discussion of the challenges the nation faces: widening inequality, dangerous debt levels, an aging population.

Mr. Xi himself has acknowledged that the party must adapt, declaring that the nation is entering a “new era” requiring new methods. But his prescription has largely been a throwback to repression, including vast internment camps targeting Muslim ethnic minorities. “Opening up” has been replaced by an outward push, with huge loans that critics describe as predatory and other efforts to gain influence — or interfere — in the politics of other countries. At home, experimentation is out while political orthodoxy and discipline are in.

In effect, Mr. Xi seems to believe that China has been so successful that the party can return to a more conventional authoritarian posture — and that to survive and surpass the United States it must.

Certainly, the momentum is still with the party. Over the past four decades, economic growth in China has been 10 times faster than in the United States, and it is still more than twice as fast. The party appears to enjoy broad public support, and many around the world are convinced that Mr. Trump’s America is in retreat while China’s moment is just beginning.

Then again, China has a way of defying expectations.