SANTIAGO, Chile — They killed Tony the Tiger. They did away with Cheetos’ Chester Cheetah. They banned Kinder Surprise, the chocolate eggs with a hidden toy.

The Chilean government, facing skyrocketing rates of obesity, is waging war on unhealthy foods with a phalanx of marketing restrictions, mandatory packaging redesigns and labeling rules aimed at transforming the eating habits of 18 million people.

Nutrition experts say the measures are the world’s most ambitious attempt to remake a country’s food culture, and could be a model for how to turn the tide on a global obesity epidemic that researchers say contributes to four million premature deaths a year.

“It’s hard to overstate how significant Chile’s actions are — or how hard it has been to get there in the face of the usual pressures,” said Stephen Simpson, director of the Charles Perkins Centre, an organization of scholars focused on nutrition and obesity science and policy. The multibillion dollar food and soda industries have exerted those pressures to successfully stave off regulation in many other countries.

Since the food law was enacted two years ago, it has forced multinational behemoths like Kellogg to remove iconic cartoon characters from sugary cereal boxes and banned the sale of candy like Kinder Surprise that use trinkets to lure young consumers. The law prohibits the sale of junk food like ice cream, chocolate and potato chips in Chilean schools and proscribes such products from being advertised during television programs or on websites aimed at young audiences.

Beginning next year, such ads will be scrubbed entirely from TV, radio and movie theaters between 6 a.m. and 10 p.m. In an effort to encourage breast-feeding, a ban on marketing infant formula kicks in this spring.

Still craving Coca-Cola? In Chile, beverages high in sugar include an 18 percent tax, which is among the steepest soda taxes in the world.

The linchpin of the initiative is a new labeling system that requires packaged food companies to prominently display black warning logos in the shape of a stop sign on items high in sugar, salt, calories or saturated fat.

The food industry calls the rules government overreach. Felipe Lira, the director of Chilealimentos, an industry association, said the new nutrition labels were confusing and “invasive,” and that the marketing restrictions were based on a scientifically flawed correlation between the promotion of unhealthy foods and weight gain. “We believe that the best way to approach the problem of obesity is through consumer education that changes people’s habits,” he said in an emailed statement.

PepsiCo, the maker of Cheetos, and Kellogg’s, producer of Frosted Flakes, have gone to court, arguing that the regulations infringe on their intellectual property. The case is pending.

María José Echeverria, a spokeswoman for PepsiCo, said the company was fully compliant with the law, and had no interest in overturning it, but was only trying to protect its ability to use a locally registered trademark.

Kellogg declined to comment.

Soaring obesity rates are forcing governments around the world to confront one of the more serious threats to public health in a generation.

Until the late 1980s, malnutrition was widespread among poor Chileans, especially children. Today, three-quarters of adults are overweight or obese, according to the country’s health ministry. Officials have been particularly alarmed by childhood obesity rates that are among the world’s highest, with over half of 6-year-old children overweight or obese.

In 2016, the medical costs of obesity reached $800 million, or 2.4 percent of all health care spending, a figure that analysts say will reach nearly 4 percent in 2030.

Such sobering statistics helped rally a coalition of elected officials, scientists and public health advocates who overcame fierce opposition from food companies and their allies in government.

“It was a hard-fought guerrilla war,” said Senator Guido Girardi, vice president of the Chilean senate and a doctor who first proposed the regulations in 2007. “People have a right to know what these food companies are putting in this trash, and with this legislation, I think Chile has made a huge contribution to humanity.”

From India to Colombia to the United States, countries rich and poor have been struggling to combat rising obesity — and encountering ferocious resistance from food companies eager to protect their profits.

In Chile, corporate interests delayed passage of the law for almost a decade, and on two occasions there were so many lobbyists crowding Congressional hearings for the bill that the Senate president was forced to suspend the sessions and clear the room.

But the industry rarely faces opponents like Senator Girardi. A trained surgeon with a flair for the theatrical, he is a key figure in the governing coalition of President Michelle Bachelet. During the long fight over the food law, Senator Girardi, 56, publicly assailed big food companies as “21st century pedophiles” and before Ms. Bachelet took office, spent weeks protesting outside the presidential palace with placards that accused her predecessor, Sebastián Piñera, of destroying the nation’s health by vetoing an earlier version of the legislation.

“Sugar kills more people than terrorism and car accidents combined,” he said in an interview as he shook a box of Trix cereal for effect. “It’s the poison of our time.”

There were other factors that made the legislation possible, including a legislature determined to address the rising economic costs of obesity and support from Ms. Bachelet, a socialist who also happens to be trained as a pediatrician.

In the end, industry pressure succeeded in easing some measures in the original legislation, including loosening the advertising restrictions and quashing a proposed ban on junk food sales near schools.

Strolling through a Chilean supermarket can be visually jarring. Boxes of Nesquick chocolate powder no longer include Nestle’s hyperkinetic bunny. Gone, too, are the dancing candies that enliven packages of M&Ms the world over.

Then there are the warning signs that appear on the front of countless items.

Cereal bars, yogurts and juice boxes, products long advertised as “healthy,” “natural” or “fortified with vitamins and minerals,” now carry one or more of the black warning labels. A bottle of Great Value brand light ranch dressing displays all four warning logos — marking it as high in salt, sugar, calories and fat.

“I never really paid attention to labels,” Patricia Sánchez, 32, an accountant and mother of two, said as she filled her shopping cart at a Santiago supermarket, with occasional help from her 7-year-old daughter. “But now they kind of force you to pay attention. And if I don’t notice, my kids do.”

Obesity rates in Chile have yet to fall, and experts say it could take years to significantly modify the way people eat. But by focusing on the packaging and advertising of unhealthy foods that appeal to children, the Chilean government is hoping to reprogram the next generation of consumers.

“You have to change the entire food system and you can’t do that overnight,” said Dr. Cecilia Castillo Lancellotti, former head of nutrition at the country’s Health Ministry and an early proponent of the legislation.

The new regulations, however, have prompted an unexpected payoff already: Food companies have been voluntarily modifying their products to avoid the dreaded black logos.

According to AB Chile, a food industry association, more than 1,500 items, or 20 percent of all products sold in Chile, have been reformulated in response to the law. Nestlé reduced the sugar in its Milo chocolate powder drink, McDonald’s removed French fries from most of its Happy Meals and local companies have been introducing new products like nuts, rice cakes and dried fruit to sell in schools.

Last month, Coca-Cola began an advertising campaign for new versions of Sprite and Fanta that boasts the tagline “Free of Logos, Equally Rich” — a nod to the fact that they will no longer contain warning labels because the company replaced half the sugar with artificial sweetener.

Ben Sheidler, a spokesman for Coca-Cola, said the company had created 32 new beverages in the last 18 months, and that 65 percent of its drinks portfolio in Chile could now be described as having low or reduced sugar.

A spokesman for PepsiCo said two-thirds of its beverage brands in Chile also qualified as low or sugar-free and that more than 90 percent of its snack offerings were now low in both sodium and saturated fat.

Other companies have embraced the logo system as a way to tout healthy offerings. Soprole, a Chilean dairy company, produced a commercial that features child newscasters explaining the label system in a way their peers can understand.

“Originally we didn’t believe the logos would make much of a difference but in focus groups, we’ve discovered that kids really do look at them,” said Dr. Camila Corvalan, of the University of Chile who has been assessing the impact of new label system. “They’ll say ‘Mom, this has so many logos. I can’t bring them to school. My teacher won’t allow it.”

Soon after the labels began appearing, AB Chile, the industry association, released an online ad using Chilean celebrities to attack the new regulations. In one scene, a well-known television presenter propped up in his putative sick bed considers a tray of soup, crackers and marmalade — items he said the new law has deemed unhealthy. “This is what my mom gave me all my life and I can no longer eat it?” he asks indignantly. In another, an actress pulls a mound of mints from her pocketbook. “It’s obvious that they are high in sugar,” she says. “But I only eat two or three.”

The ad prompted a fierce backlash online that went viral. . In one counterattack, the Chilean actor Pablo Schwartz posted a video of himself pondering a mound of white powder. “Everyone says cocaine is bad, of course, but would you snort a quarter kilo at once?” he asks before inhaling a bump and then adding “It’s all about portion.”

The association killed their ad criticizing the new regulations.

The job of implementing the rules falls to a group of technical advisers who gather weekly at the Ministry of Health and provide guidance on whether a snack company should remove the dancing cat logo from cookie packages or whether an adult‘s voice should replace the small, childlike one hawking corn chips on a radio spot.

“Sometimes it’s easy, like if a dog is wearing glasses and talking like a person, but sometimes it’s not,” said Dr. Lorena Rodriguez, the ministry’s head of nutrition. “We fight and fight and fight until we have consensus.”

Dr. Jaime Burrows Oyarzún, the vice minister of public health, is confident the government will prevail in court. As chief arbiter of the new regulations, he often bears the brunt of industry ire. After the banning of Kinder Surprise, a company executive from Italy and the Italian ambassador to Chile accused him of waging “food terrorism” during a visit to his office, he recalled in an interview.

Mauro Russo, managing director at Ferrero, the maker of the Kinder Surprise, said the law had been erroneously applied to their product because the toy is an intrinsic part of the treat, not a “promotional gadget,” as described by the legislation, that seeks to stimulate sales. He also disputed the notion that the product is unhealthy, noting that each egg contains 110 calories and that few consumers purchase more than one or two a year. “Kinder Surprise’s impact on obesity is very marginal,” he said.

Some nutrition advocates wonder how long the law will survive in its current form. Mr. Piñera, the former president who was recently elected to the office again and will succeed Ms. Bachelet in March, is a conservative businessman who vetoed the food bill in 2011 during his first term in office. Instead, his administration backed a nutrition initiative, financed by multinational food companies, that emphasized healthy recipes, exercise and moderation when it comes to junk food. The campaign was the project of the first lady, Cecilia Morel Montes.

“We don’t need more taxes,” she said in an interview.

A spokesman for Mr. Piñera said he would likely take a second look at the law and explore ways “to improve it” after he takes office.

In the meantime, other countries in Latin America, among them Ecuador and Brazil, are seeking to borrow elements of Chile’s initiative. Dr. Carlos A. Monteiro, a professor of nutrition and public health at the University of São Paulo in Brazil, said leaders throughout the region could no longer ignore the rising medical costs of diet-related diseases like diabetes and hypertension.

“The epidemic of obesity is so clear and harmful to the whole population, including the political elite, and no country is succeeding to control it without regulation of the food environment,” he said. “Doing nothing is no longer an option.”