Yet women doctors are paid less than men, on average, and less likely to be promoted.

"There's a lot of evidence out there that male and female physicians practice medicine a little bit differently," said Harvard's Dr. Ashish Jha, who oversaw the study.

"The data out there says that women physicians tend to be a little bit better at sticking to the evidence and doing the things that we know work better," Jha told NBC News.

And this translates into benefits for their patients, the study found. Jha and colleagues looked at the records of more than 1.5 million elderly Medicare patients admitted to hospitals for medical reasons, not for surgery, between 2011 and 2015.

"Patients cared for by female physicians had lower 30-day mortality than did patients treated by male physicians," they wrote in their report, published in the Journal of the American Medical Association's JAMA Internal Medicine.

Over the four years, just about 11 percent of the patients treated by female physicians died within a month after being in the hospital, compared to 11.5 percent of those treated by males.

David Sacks | Getty Images

And about 15 percent of the patients treated by women doctors had to return to the hospital within a month, compared to 15.5 percent of those treated by men.

It seems like a small difference but it adds up to a lot of lives, Jha's team said.

"We estimate that approximately 32,000 fewer patients would die if male physicians could achieve the same outcomes as female physicians every year," they wrote.

Yet women physicians are paid a lot less than their male counterparts, according to Dr. Anna Parks of the University of California, San Francisco.

"Despite evidence suggesting that female physicians may provide higher-quality care, some have argued that career interruptions for childrearing, higher rates of part-time employment, and greater tradeoffs between home and work responsibilities may compromise the quality of care provided by female physicians and justify higher salaries among male physicians," she wrote in a commentary.

One study found that while white male doctors earned on average $250,000 a year, white female doctors earned $163,000 a year.

Yet female physicians focus more on the patient, Parks said.

sturti | Getty Images

"Previous work has shown that female physicians have a more patient-centered communication style, are more encouraging and reassuring, and have longer visits than male physicians," she wrote.

So just maybe, if physicians were actually paid more for better performance, that would help close the pay gap between women and men.

Jha said it will be important to find out what accounts for the differences in patient results from male and female doctors and teach all doctors to change practice.

The team tried to account for some of the variables, such as the possibility that people who choose female doctors may do better for various reasons. People admitted to hospitals for treatment have less choice, or often no choice, about who their doctor is.

And they found the different success rates were the same across eight out of 10 medical conditions.