WASHINGTON — Immigrants in the United States both legally and illegally are helping sustain Medicare, contributing about $14 billion more a year to the federal health program for the elderly than they use in medical services, a new study indicates.

The surplus generated by immigrants contrasts sharply with deficits caused by native-born Americans, as medical care for elderly beneficiaries depletes Medicare's reserves more quickly than working-age U.S. natives can refill them.

The report, published Wednesday in the journal Health Affairs as Congress debates immigration overhaul legislation, does not calculate the full impact of immigrants in the country illegally on all government health care programs.

But the authors estimate that these immigrants are helping to support the Medicare program because many pay taxes, while they are ineligible to receive benefits.

"Our study should raise skepticism about the widespread assumption that immigrants drain public health care resources," said Dr. Leah Zallman, an internist and Harvard Medical School instructor who is lead author of the report.

Most legal immigrants, like U.S. citizens, become eligible for Medicare benefits at 65 if they have worked at least 40 quarters in this country. That means many immigrants who today sustain the program will someday draw benefits. But the authors note that, as long as immigration continues, immigrants should not be a drain on the program.

"Policies that reduce immigration would almost certainly weaken Medicare's financial health, while an increasing flow of immigrants might bolster its sustainability," the study concludes.

Medicare, which covers about 50 million retired and disabled Americans, is funded partly through payroll taxes that employers and employees pay into a trust fund.

But that fund is slowly being drained as a wave of native-born baby boomers retires and health care costs continue to rise, if more slowly than in past years. Medicare's main trust fund is projected to run in the red in 2024.

Today, less than 60 percent of the U.S.-born population is 18 to 64. By contrast, nearly 80 percent of foreign-born residents are in their prime working years.

The United States is home to an estimated 40 million foreign-born residents, among whom about 11 million have entered the country illegally or overstayed their visas.

By looking at census data, researchers were able to estimate that people born abroad likely paid about $33 billion in payroll taxes to the Medicare trust fund in 2009. The researchers then used Medicare data to estimate that immigrants were responsible for about $19 billion of the program's medical expenses that year.