Joseph Robertson / Getty Images

Kids who live in states with strict laws regulating the sale of junk food and sugary drinks in school gain less weight than their peers in states with weak or no such laws, according to a new study published online in the journal Pediatrics.

The study looked at data on 6,300 students in 40 states, tracking their height and weight between 2004 and ’07, from fifth to eighth grade. Six states had strict laws restricting the sale of so-called competitive foods — snacks and drinks sold in vending machines, school stores and during fundraising projects, which compete with school-served meals; seven states had weak laws; and 27 states had no laws governing competitive foods in middle schools.

Laws were considered strong if they included specific nutrition standards — like limiting sugars and fats. They were labeled as weak if they were vague, suggesting the sale of “healthy” foods, for example, without giving detailed guidelines.

(MORE: Disney’s Diet: No More Junk-Food Ads on Kids Channels)

Between fifth and eighth grades, the researchers found, kids living in states with strong competitive-food laws gained less weight than other kids — about 2.2 lb. less for a 5-ft. tall, 100-lb. child, for example. Those kids who were already obese in fifth grade were also more likely to have reached a healthy weight by eighth grade, if they lived in a state with strict laws.

The study is the first to take a broad look at the effectiveness of competitive-food laws nationwide. The effect of those laws was modest, and the researchers couldn’t definitively say that the laws directly caused healthier weights in kids, but the findings are encouraging and likely to inform the debate over how best to curb child obesity. Many public-health officials and obesity experts support banning junk food from schools, while the packaged-food industry and school districts that make money off those products oppose such laws. Critics of regulation also note that school accounts for only one small factor in a child’s overall food environment and that banning junk food during the school day won’t do much good if kids go home to more unhealthy choices.

But while child obesity is a complex problem with a multitude of causes, the study’s data suggest that competitive-food laws may have a measurable impact on kids’ weight. “Competitive-food laws can have an effect on obesity rates if the laws are specific, required and consistent,” study co-author Daniel Taber, a health-policy researcher at the University of Illinois at Chicago, told the New York Times.

(MORE: Watching TV Steers Children Toward Eating Junk)

In states with strong competitive-food laws, nearly 39% of fifth-graders were overweight and 21% were obese at the beginning of the study. By eighth grade, those rates had fallen to 34% and 18%, respectively. In states with weak or no laws, 37% of fifth-graders were overweight and 21% were obese, and there were no real changes to those rates by the time the students entered eighth grade.

According the Centers for Disease Control and Prevention, child-obesity rates have tripled in the past 30 years: in 2008, more than a third of children and adolescents were overweight or obese, putting them at risk for heart disease and diabetes.

Even if competitive-food laws have only a small effect in turning that tide, “What are the downsides of improving the food environment for children today?” Dr. David Ludwig, an obesity specialist at Harvard Medical School and Boston Children’s Hospital, commented to the Associated Press. “You can’t get much worse than it already is.”

MORE: The Sad State of American Kids’ Food Environments

LIST: Top 10 Iconic Junk Foods