A large federal study of whether diet and weight loss can prevent heart attacks and strokes in overweight and obese people with Type 2 diabetes has ended two years ahead of schedule because the intensive program did not help.

“I was surprised,” said Rena Wing, the study’s chairwoman and a professor of psychiatry and human behavior at Brown University’s medical school.

Like many, she had assumed diet and exercise would help, in part because short-term studies had found that those strategies lowered blood sugar levels, blood pressure and cholesterol levels.

But, Dr. Wing added, “You do a study because you don’t know the answer.”

Still, medical experts said there were many benefits to diet and exercise even if they did not reduce cardiovascular disease in people with diabetes.