BEIJING — In Chinese schools, students learn that the United States became a great nation partly by stealing technology from Britain. In the halls of government, officials speak of the need to inspire innovation by protecting inventions. In boardrooms, executives strategize about using infringement laws to fell foreign rivals.

China is often portrayed as a land of fake gadgets and pirated software, where intellectual property like patents, trademarks and copyrights are routinely ignored. The reality is more complex.

China takes conflicting positions on intellectual property, ignoring it in some cases while upholding it in others. Underlying those contradictions is a long-held view of intellectual property not as a rigid legal principle but as a tool to meet the country’s goals.

Those goals are getting more ambitious. China is now gathering know-how in industries of the future like microchips and electric cars, often by pushing foreign companies attracted by the country’s vast market into sharing their technology. It is also toughening enforcement of patents and trademarks for a day when it can become a leader in those technologies — and use intellectual property protections to defend its position against rival economies.

President Trump is expected to announce as early as Monday the opening salvo in what could become a far-reaching investigation into Chinese trade practices. He has spoken forcefully about the need to protect American intellectual property, accusing Chinese companies of stealing jobs and technology.

Mr. Trump’s demands are likely to be met with deep skepticism in Beijing.

President Xi Jinping is in the midst of an effort to strengthen laws on patents, copyrights and trademarks, giving fledgling firms in China new sources of revenue and prestige. The country is also pursuing an ambitious plan, called Made in China 2025, to become a global leader in areas like robotics and medical technology and kick off the next phase of China’s development. The efforts reflect the view of Chinese officials that controlling global technologies and standards is on par with building military muscle.

Zhang Ping, a scholar of trade law at Peking University in Beijing, said the West had long used intellectual property laws as a “spear and shield” against Chinese companies, hurting their profits at home and blocking access to foreign markets. Now, she said, it is time for China to fight back.

“If you want to enter our market to cooperate, it’s fine,” Ms. Zhang said, “but you can’t grab us by the neck and not let us grow.”

Trademarks and patents protect companies and inventors, compensating them for their time, ideas and investment. While poorer countries have throughout history worked to obtain inventions from wealthier nations, sometimes running afoul of intellectual property laws, China has rewritten the playbook for acquiring advanced technology.

Since Deng Xiaoping, as leader, opened the Chinese economy to the outside world nearly four decades ago, the country has made it a priority to obtain ideas and inspiration from overseas.

Sometimes it has reverse-engineered what it wants. United States officials say that Chinese companies have also carried out extensive economic espionage through cyberattacks and other means. (Chinese officials have denied those charges.) More recently, China has used its growing wealth to buy into cutting-edge technologies, like genetically modified crops and the latest innovations from American start-ups, and to attract promising talent.

But since those early days, China has relied heavily on one tried-and-true method: forming joint ventures with foreign partners. Big-name companies like I.B.M. and Qualcomm are required to share advanced technology and research with domestic firms in order to set up shop in China. And to entice partners, the country offers access to its enormous market and hundreds of millions of consumers.

Joint ventures helped China build whole industries out of scratch. After using them to explore high-speed rail technology, Chinese firms now dominate the global industry.

Chinese experts say those moves are simply smart deal-making, not violations of intellectual property laws, allowing the country to harness its leverage as the world’s second largest economy to win practical knowledge.

But now China’s efforts are moving beyond routine manufacturing into cutting-edge technologies — and the Trump administration has denounced the arrangements as coercive.

In April, the Office of the United States Trade Representative accused China of “widespread infringing activity,” including stealing trade secrets, tolerating rampant online piracy and exporting counterfeit goods.

Chinese commentators see hypocrisy in American criticism, noting that the United States was once one of the world’s leading pirates, when it worked to challenge British industrial dominance after the American Revolution by obtaining designs for inventions like steam-powered looms. The state-run news media has highlighted the case of Samuel Slater, often called the father of the American industrial revolution, who brought British textile designs to the United States in the late 1700s.

Still, as China comes up with its own innovations, the country’s leaders are embracing stricter laws on patents, copyrights and trademarks.

The government has created specialized courts to handle intellectual property disputes and awarded subsidies to entrepreneurs who file patent applications. In 2015, more than a million were filed, a record amount.

Li Jian, a vice president of Beijing East IP, a Chinese law firm, said mainland companies increasingly saw strong intellectual property protections as a tool to help protect inventions and earn royalties overseas.

“Many Chinese companies have realized that through patent protection they can gain an advantage in the market,” Mr. Li said. “They have more faith now in the Chinese government to protect their intellectual property.”

The rules have also benefited some foreign firms. New Balance won a landmark case this year against a Chinese company that used its signature slanting “N” logo. China’s highest court last year gave Michael Jordan the rights to Chinese characters of his name.

Enforcement is still inconsistent, experts say. Local officials are often reluctant to aid foreign companies, worried about jeopardizing tax revenues from homegrown companies.

The Made in China 2025 initiative is a key reason the country is improving intellectual property rights. The plan focuses on sectors like electric cars, robotics, semiconductors and artificial intelligence.

By forcing foreign companies to hand over more technology and encouraging local companies to make new products based on that technology, Chinese leaders hope to cement the country’s dominance in critical fields. They also see an opportunity to dictate the terms of the future development of technology and extract licensing fees from foreign firms that use Chinese-made technology.

Several trade organizations and governments have said the plan is protectionist. Some have called for reciprocity, arguing that the United States should impose on Chinese companies the same restrictions China places on foreign companies.

“There is an unmistakable national policy to boost the position of Chinese companies in cutting-edge areas,” said William P. Alford, a Harvard law professor and an expert on Chinese intellectual property laws.

Chinese experts have defended the strategy.

“To become an adult, you have to accumulate knowledge,” said Professor Zhang, of Peking University. “It’s the same for a country.”

As China’s power has grown, Chinese companies have started using intellectual property laws to fend off foreign rivals.

When the United States International Trade Commission last year began investigating Chic Intelligent Technology Company, a manufacturer of self-balancing scooters based in the eastern city of Hangzhou, the company’s executives fought back. The commission was looking into claims that Chic had copied product designs of a California-based competitor, Razor USA.

Chic filed retaliatory lawsuits against American competitors, adopting many of the tactics that American companies have used for years to hobble Chinese competitors. The trade commission has since declined to ban imports of the Chic scooters. The lawsuit against Razor USA remains unresolved, according to Chic.

Chic made clear that it saw the investigation as an effort by the United States to use intellectual property laws to bully Chinese companies. In a statement, the company’s leaders compared American regulators to Japanese invaders during World War II.

“The crazier the enemy,” the statement said, “the more we need to prove the necessity of our siege.”