Six years ago, when tainted infant formula killed six babies in China and sickened 300,000, one of the biggest foreign investors in the sector was caught by surprise.

The investor, the Fonterra Cooperative Group of New Zealand, one of the world’s largest dairy companies, had put millions of dollars into a partnership with the Sanlu Group, a Chinese maker of infant formula that was one of several found to have mixed an industrial chemical into milk powder to artificially raise protein readings.

Sanlu was declared bankrupt, and four of its executives were imprisoned. Fonterra was forced to write down the entirety of its investment of 200 million New Zealand dollars, or about $167 million at current exchange rates, in the Chinese venture.

Yet on Wednesday, Fonterra became the latest foreign company to make a new bet that it could turn a profit by bringing safer food to China. The company said it would spend more than $500 million in a deal with the Beingmate Baby and Child Food Company, a Chinese manufacturer of infant formula. A day earlier, Kohlberg Kravis Roberts, an American private equity giant, announced an investment of about $400 million in China’s largest chicken breeder, Fujian Sunner Development, in a deal intended to improve food safety and quality.

“China is a completely different environment now; Beingmate is a completely different partner,” Theo Spierings, the chief executive of Fonterra, said on Wednesday in response to questions from reporters about the Sanlu episode, according to Reuters. “We are very focused on learning from the past and moving on to the future.”

Food safety scandals occur with disturbing frequency in China. This week alone, according to reports in the state-run news media: The authorities seized more than 30,000 tons of chicken feet, a common menu item in China, that had been contaminated by a hydrogen peroxide cleaning agent; and in Zhejiang Province, 17 people were in court on accusations of selling 38 tons of dog meat — consumed in parts of the country — that had been poisoned when the animals were slaughtered with cyanide or overdoses of anesthetics.

The challenge confronting big foreign food companies in China is how to ensure that their standards are enforced by all workers at all stages of the food supply chain. Ignorance can be a more common problem than outright deception, experts say.

“Most of the time it’s not that something is being hidden, it’s more that the people are not aware of the standards that Western companies expect,” said Sébastien Breteau, the chief executive of AsiaInspection. The company conducts spot checks on all kinds of factories in China on behalf of the companies they supply, and among food factories, the failure rate for inspections so far this year has been more than 50 percent.

“What I’ve seen,” Breteau said, “when you sit down in a factory and you explain what matters for a client, if you train them over more demanding standards in terms of manufacturing, then they catch up with it very quickly.”

Although food companies with foreign backing are often financially stronger and are perceived as having higher quality and safety standards, some prominent lapses in China have shown that such companies can still run into problems. Fonterra’s investment in Sanlu was an early example. Last week, the American food producer H. J. Heinz recalled several batches of baby cereal products after they were discovered to contain high levels of lead.

And last month, the OSI Group, an American-owned supplier for McDonald’s, KFC and other fast-food chains, became the subject of an investigation by the police and food safety officials in Shanghai. A local television station had broadcast a program accusing OSI employees of doctoring labels to extend expiration dates on chicken and beef products and showed footage seemingly of workers scooping up meat from the floor and putting it back on conveyor belts for processing.

For OSI, which is based in Aurora, IL, and had been known for its industry-leading operations and quality control, the episode was jarring. In response to food safety concerns in China, it had invested hundreds of millions of dollars building a chicken-meat supply chain in the country that included a feed mill, hatcheries and slaughtering operations. In the United States, it focuses on processing meat that is purchased from other suppliers.

In the Fonterra deal, which is subject to regulatory approvals and calls for it to take a 20 percent stake in Beingmate, the two companies will import infant formula ingredients from Fonterra’s dairies and manufacturing sites in New Zealand, Australia and Europe for sale in China.

“Extensive due diligence has taken place from both sides,” said Spierings of Fonterra, “and we have made arrangements on governance very clear.”

Experts say that China’s food industry tends to be highly competitive and to have low profit margins, meaning that businesses can be tempted to skip steps to save money, in some cases turning a blind eye to possible dangers to consumers.

“Producing food as a business is not the same as producing T-shirts,” said Peter Karim Ben Embarek, a food safety scientist at the World Health Organization in Geneva who was previously based in China. “If you cut corners making T-shirts, some customers might be upset, but if you do it with chickens, you might end up killing people.”

He added: “You have a bit of a Wild West situation where the public oversight is still lacking in terms of on-the-ground implementation.”

Gao Guan, the deputy secretary of the China Meat Association, said one problem is that China does not have enough food inspectors.

“The level of regulation and enforcement is too low,” Gao said. He cited recurring problems at meat processors, which can be reckless in their pursuit of profit. “If you rely on the individual processors, then you will never be able to enforce safety standards, because everybody is just trying to make fast money.”