Of all the economic rifts between the United States and China, one felt personally by American executives is what they describe as the difficult, even hostile, conditions they face doing business in China.

Treasury Secretary Janet L. Yellen laid bare those concerns on Friday by leveling a forceful objection in Beijing to punitive measures the Chinese government has taken against foreign firms, as tension between the two nations has escalated.

Surrounded by executives from some of the most powerful American companies, Ms. Yellen criticized the Chinese government’s harsh treatment of companies with foreign ties and its recent decision to impose export controls on certain critical minerals. She suggested that such actions justify the Biden administration’s efforts to make U.S. manufacturers less reliant on China.

Ms. Yellen’s comments, made to a group of executives from American businesses operating in China, underscored the challenges that the world’s two largest economies face as they struggle to reconcile their deep differences.

The forceful defense of American industry came on Ms. Yellen’s first day of meetings in Beijing during a high-stakes trip to ease tension between the United States and China. She conveyed her objections to China’s top officials, including Premier Li Qiang, in what was the first visit to China by a Treasury secretary in four years.

“During meetings with my counterparts, I am communicating the concerns that I’ve heard from the U.S. business community — including China’s use of nonmarket tools like expanded subsidies for its state-owned enterprises and domestic firms, as well as barriers to market access for foreign firms,” Ms. Yellen said at an event held by the American Chamber of Commerce in China. “I’ve been particularly troubled by punitive actions that have been taken against U.S. firms in recent months.” Representatives of Boeing, Bank of America and the agriculture giant Cargill were among those in attendance.

In March, the Chinese authorities detained five Chinese nationals working in Beijing for the Mintz Group, an American consulting company with 18 offices around the world, and closed the branch. The next month, the authorities questioned employees in the Shanghai office of Bain & Company, the U.S. management consulting firm.

Scrutiny of American businesses operating in China followed restrictions that the Biden administration imposed on China’s access to critical semiconductor-making technology and tools.

The Biden administration is preparing additional restrictions on U.S. technology trade with China, including potential limits on advanced chips and U.S. investment in the country. The administration is also preparing to restrict Chinese companies’ access to U.S. cloud computing services to curtail China’s use of advanced chips for artificial intelligence.

The tit-for-tat continued this week when Beijing retaliated against the Biden administration’s limits on semiconductors, announcing that it would restrict the export of certain critical minerals used in the production of some chips. Ms. Yellen said on Friday that she was “concerned” by China’s export controls and suggested that additional responses from the United States could be looming.

An official from China’s ministry of finance expressed hope on Friday that the meetings with Ms. Yellen would improve economic relations and suggested that the United States needs to take steps to make that happen. The official added that neither country benefits from “decoupling” and disrupting supply chains.

Longtime observers of the U.S.-China relationship were skeptical of the chances of a swift breakthrough.

Shi Yinhong, a political scientist at Renmin University in Beijing, said Ms. Yellen’s visit could not be expected to “really mitigate substantially” the numerous and broad differences between the two countries. But given those differences, he said, Chinese officials were unlikely to be surprised by Ms. Yellen’s remarks in support of American businesses in China.

“I doubt that the Chinese side would have much higher expectation at all,” he said.

U.S. businesses have been alarmed by China’s ever-tightening national security laws, which include a stringent counterespionage law that took effect on Saturday. The U.S. State Department issued a warning this week advising Americans to reconsider traveling to China because of the possibility of wrongful detention.

Michael Hart, the president of the Chamber, said American companies are trying to play a constructive role in the economic relationship between the United States and China.

“We’ve been trying, regardless of what’s happened at the political level, to find common cause with our Chinese counterparts by employing, manufacturing, producing, buying, selling, paying our taxes and doing it all in a manner that reflects our values,” Mr. Hart, who was seated next to Ms. Yellen, said.

The Treasury secretary planned to raise these issues during a blitz of meetings with top Chinese officials over the next two days.

While Ms. Yellen laid out the grievances of American businesses, Chinese companies have felt a chill of distrust in the United States, which the Chinese officials meeting Ms. Yellen were likely to press her on.

“Unfortunately, these relationships that have been mutually beneficial have now become politicized, securitized and even demonized — treated as having an impact on national security,” said Wang Yong, the director of the Center for American Studies at Peking University. “But I personally think that while there is so-called strategic competition between China and the United States, they still have many common interests.”

Chinese businesses have been unsettled by recent U.S. actions, such as the congressional hearings about the Chinese-owned social media network TikTok, and by the deepening American barriers to Chinese investments and corporate deals, including in once prosaic sectors such as farmland purchases, Professor Wang added.

Ms. Yellen also met on Friday with Liu He, China’s former vice premier, and Yi Gang, the outgoing governor of the People’s Bank of China. A Treasury Department official said that Ms. Yellen discussed the outlook for the economy in an informal discussion with her former counterparts that lasted more than an hour.

Later on Friday afternoon, she met with Mr. Li at the Great Hall of the People, which sits on the edge of Tiananmen Square.

Ahead of her meeting with Mr. Li, China’s No. 2 leader, Ms. Yellen emphasized the importance of “healthy competition” between the two nations and stressed that measures taken by the United States on the basis of national security should not be misconstrued as attacks on China.

“The United States will, in certain circumstances, need to pursue targeted actions to protect its national security,” Ms. Yellen said. “And we may disagree in these instances.”

She added: “However, we should not allow any disagreement to lead to misunderstandings that needlessly worsen our bilateral economic and financial relationship.”

Seated next to Ms. Yellen, Mr. Li noted that the world had high expectations for their meeting.

Offering a ray of optimism, the premier noted that when Ms. Yellen arrived in Beijing, she was photographed pointing to a rainbow in the sky and suggested that it was a sign that the relationship between China and the United States could be mended.

“I’m really looking forward to this opportunity to have an exchange of views with you,” Mr. Li said through an interpreter.

Claire Fu, Keith Bradsher and Christopher Buckley contributed reporting.