A shopper stops at the best-selling goods shelf for all kinds of processed meat. Slowing growth, rising costs and investment barriers temper the optimism of many U.S. CEOs. (Zhang Peng/LightRocket via Getty Images)

China is the fastest-growing major economy in the world and has seemed to hold boundless promise for foreign companies. In a country once inhabited by people in Mao suits, an expanding and urbanizing middle class is hungry for Western goods. One U.S. retailer alone — Gap — expects to triple its sales of clothing between 2013 and 2016.

But a growing cluster of problems is confronting foreign companies here, leading many executives to wonder where the good times might have gone.

A slowdown in China’s breakneck economic growth, stiffer competition from Chinese companies and rising labor costs have combined to cut into the profit margins of U.S. companies operating here. Many executives say they think the playing field is being tipped against them by a government that favors domestic companies, or they complain about being excluded from key sectors of the economy by laws restricting foreign investment. Meanwhile, hazardous levels of air pollution here make it increasingly hard to recruit foreign executives.

In a possible sign of the growing disenchantment, U.S. investment in China fell 9.3 percent in the first five months of 2014 compared with the same period last year. Although such numbers are volatile, the decline in investment from Europe was even bigger.

“Perhaps the golden age for multinationals in China is over,” said Duncan Clark, chairman of investment advisory firm BDA.

To be sure, enticing opportunities remain — in the established business of selling airplanes, for instance, or partnerships in the movie industry, and in consumer goods and financial services. But double-digit profit is much harder to come by than it was two decades ago. China has become a maturing market with a host of challenges, many linked to its Communist Party-directed economic model.

“What has changed is that the easy money, the easy opportunities, the lower-hanging fruit, have started to go away,” said Christian Lundblad, a professor of finance at the University of North Carolina’s Kenan-Flagler Business School. “So those nagging things that have always been there are starting to become a bit more pronounced. The opportunities are getting more complicated than they used to be.”

And there has been a change in how foreign investors are treated. In the past, executives recall, China treated foreign chief executives almost like visiting heads of state, ushering them around in official convoys for audiences with the president and promising them tax breaks to set up factories. Today, foreign CEOs are almost as likely to be condemned by regulators or state media for exploiting Chinese consumers as they are to be glad-handed by top leaders.

“Foreign companies have an opportunity in China if they are doing something that China needs or doing something that China can’t do,” said James McGregor, greater China chairman of APCO Worldwide, a consulting firm. McGregor says the environment for foreign companies is growing more difficult as Chinese companies grow stronger. “There is less that China can’t do and less that China needs.”

A boom hits roadblocks

In the 1980s and 1990s, U.S. manufacturers flocked to China to take advantage of low wages and a vast new consumer market. In the 2000s, with its accession to the World Trade Organization, China lowered tariff barriers or relaxed import quotas on thousands of goods, from cars to drinks to textiles. From 2004 to 2013, U.S. exports to China increased by 255 percent.

The growth in the Chinese market has been staggering. Over the past 30 years, about 300 million people have moved into China’s middle class; the Organization for Economic Cooperation and Development estimates that 200 million more will join them by 2026.

Adding to the appeal of that market, China is trying to persuade people to spend more so that growth relies less on exports and state-directed investment in infrastructure, such as roads and power plants, and more on consumer spending and market forces.

But foreign companies are increasingly frustrated that they can’t take advantage of many of the best opportunities. Tight regulations prohibit or sharply restrict foreign investment in many parts of China’s economy, especially where giant state-owned companies dominate. In telecommunications, banking, oil and shipbuilding, for example, the state’s champions hold sway, boosted by subsidies, cheap loans and often a free pass from regulators.

Government procurement, a market estimated to be worth $1.3 trillion, is largely closed to foreign businesses, and industry standards are often written to favor domestic companies.

The U.S.-China Business Council says China restricts investment in more than 100 sectors, including agriculture, petrochemicals and health services. The United States, the business council reports, restricts investment outright in five sectors and imposes mostly minor limits on Chinese investment in 24 other sectors.

Partly as a result, China’s investment in the United States, estimated at about $14 billion, now outpaces the amount of money flowing the other way.

In various sectors, many foreign companies can operate in China only if they form joint ventures with domestic firms. Some of those partnerships work well, but very many don’t, executives say.

U.S. heavy-equipment manufacturer Caterpillar learned the hard way. Its 2012 acquisition of a Chinese subsidiary for $677 million was feted as one of the cross-border deals of the year until the U.S. firm found evidence that the Chinese company’s books had been cooked. It was forced to write off 86 percent of the deal’s value, about $580 million.

Although surveys conducted by the U.S.-China Business Council and the American Chamber of Commerce in China, or AmCham China, show that China remains among the top three investment destinations for their members, it is no longer the unassailable No. 1.

The European Union Chamber of Commerce in China described a “new sober reality” after surveying its members here.

Last year, Chinese President Xi Jinping promised far-reaching reforms to deepen the role of market forces in allocating resources and to reduce the role of the government. But there has been little follow-through, trade groups say.

“There is uncertainty about policy direction, and that is something China needs to be aware of,” said John Frisbie, president of the U.S.-China Business Council.

Business leaders are urging the Obama administration to push hard for a bilateral investment treaty being negotiated with China. That, they say, will help bring down many of the barriers to U.S. investment here and could be as transformative to the economic relationship as China’s accession to the WTO.

IT troubles

Nowhere are the problems for U.S. companies as pronounced as in the information technology sector. Revenues for companies such as Cisco Systems, IBM and Oracle were hit hard last year in the wake of revelations by National Security Agency contractor Edward Snowden about extensive American spying on foreign governments.

After the leaks, China accelerated plans to switch from foreign IT suppliers to more-trusted domestic brands. The predicament for U.S. companies only got worse when the U.S. Justice Department indicted five Chinese military officers in May on charges of cyber-espionage.

Shortly afterward, China banned the use of Microsoft’s Windows 8 on government computers; state media also branded Google, Facebook, Apple and Yahoo as “pawns” of the U.S. government and deserving of punishment for allegedly stealing China’s state secrets.

Roughly half of executives surveyed by AmCham China said they think that foreign companies are often unfairly targeted in official anti-corruption or monopoly-pricing campaigns, while politically connected domestic companies get an easier ride.

Choking air pollution is another hazard to foreign businesses, driving many executives and their families to flee Beijing and others to turn down jobs here.

APCO’s McGregor has spent about 25 years in Beijing and raised his children here, but he is about to leave in search of cleaner air.

“It has always been polluted,” he said, “but in the last few years, there are some days when you feel like it’s the end of the world.”

Nevertheless, McGregor won’t be turning his back on China: He is moving only as far as Shanghai.

“Most foreign companies know it’s going to be a rough ride, but it’s a growth market, so they have to be here,” he said. “I don’t think foreign companies are saying, ‘Great, I get to be in China,’ ” he said. “They have to be in China, so they grin and bear it.”