Jamie Grill / Getty Images

“It’s easy to quit smoking,” Mark Twain supposedly said. “I’ve done it hundreds of times.”

Something similar could be said of losing weight: It’s relatively easy to drop a few pounds, but keeping them off is much trickier. That explains why so many people fall into the classic pattern of yo-yo dieting, in which they lose weight, gain it back, lose it again, and so on.

A new study from researchers at Stanford University may point the way toward breaking out of this cycle. Weight loss might be more lasting, the study suggests, if dieters get the hang of certain healthy habits—such as eating mindfully and taking brief walks—before actively trying to lose weight.

The study, which appears in the Journal of Consulting and Clinical Psychology, included 267 mostly obese women who were randomly split into two groups. Half of the women began a weight-loss regimen immediately. The other half eventually followed the same regimen, but first went through an eight-week program in which they fine-tuned their lifestyle and learned to stabilize their weight.

Health.com: Little Ways to Drop the Pounds and Keep Them Off

Both groups of women ultimately slimmed down by the same amount—roughly 17 pounds, on average (or 9% of their initial body weight). But over the course of the following year, the women who participated in the eight-week program regained an average of just 3 pounds, compared to 7 pounds in the other group.

“They cut that regain in half,” says lead author Michaela Kiernan, a senior research scientist at the Stanford Prevention Research Center, in Palo Alto, Calif.

The dieting portion of the study lasted 20 weeks and featured all of the hallmarks of conventional weight-loss programs. Women met weekly with a trained instructor, kept food journals, exercised more, and followed a healthy diet focused on fruits and vegetables.

Health.com: Best Superfoods for Weight Loss

The eight-week lead-in program was unusual by comparison. Not only were the women instructed not to lose weight, but they were also told to gain it back if they did. This was designed to teach the women how to recognize and control the normal 3- to 5-pound fluctuations that occur even among people of healthy size, Kiernan says.

In addition, the women learned to control portion sizes, savor their meals, and identify healthy substitutes for their favorite high-calorie foods. To accustom the women to the ups and downs that go with dieting, the researchers even encouraged them to periodically indulge in a less-than-healthy food (like chocolate), and gave them a five-day pass—meant to simulate a vacation—during which they could eat high-calorie, high-fat foods.

“We purposely designed the study so they would do this before they lost weight,” Kiernan says. “They could see and experience what it was like, and thus obtain a sense of mastery without the pressure of having to maintain a weight loss at the same time.”

Health.com: Diet Crutches: What Works, What Doesn’t

Focusing on weight-maintenance skills before worrying about weight loss seems to have created a “teachable moment” for the study participants, says Linda Stockman, a weight-loss coach at Scott & White Healthcare, in Temple, Texas.

Often, dieters who successfully lose weight “get really excited by the weight loss, go off to enjoy it, and gain it back,” says Stockman, who was not involved in the study. “That eight weeks is a kind of cognitive behavioral approach, where they try things and experience things. And that’s the only way to get people to change their belief systems.”

The training program also may have fostered a sense of accountability and resolve heading into the weight-loss phase, says Lindsey Battistelli, manager of the weight management center at Henry Ford Health System, in Wyandotte, Mich.

“It takes effort to maintain a weight loss,” Battistelli says. “You can’t go back to doing what you were doing before. You can let yourself indulge here and there, as long as you’re willing to have it as part of a compromise.”

Health.com: Willpower Secrets From the Pros

Although the new findings are promising, Kiernan and her coauthors say their program will need to be tested in different populations. Most of the participants were white, college-educated women, making it difficult to extrapolate the findings to other women or to men.

Longer studies also are needed. Even the study participants who gained back relatively little weight tended to do so towards the end of the one-year study period, which may indicate the first signs of a relapse that wasn’t fully registered in the results, Kiernan notes.