Sen. Bernie Sanders' ambitious plan to overhaul the nation's healthcare system would grant coverage to those residing in the country illegally.

The Vermont lawmaker's new bill, which was introduced Wednesday, states that "every individual who is a resident of the United States is entitled to benefits for health care services." The Secretary of Health and Human Services would "promulgate a rule that provides criteria for determining residency for eligibility purposes under this Act."

Even if an individual is not covered under a broad definition of "residency" by the secretary of HHS, the federal government can take steps "to ensure that every person in the United States has access to health care."

But the bill states that the federal government would create a rule barring foreigners from coming to the United States for the sole purpose of receiving free healthcare.

Sanders' new Medicare for All proposal was co-sponsored by fellow 2020 Democratic presidential hopefuls Sens. Cory Booker of New Jersey, Kirstin Gillibrand of New York, and Elizabeth Warren of Massachusetts.

Such a program would transfer all private insurance plans to a government-run single-payer plan over four years. Things such as premiums, co-pays, and deductibles would be completely eliminated.

Sanders' bill closely mirrors the measure he proposed during his previous run for president in 2016. His new bill features even more generous benefits, including funding for long-term healthcare for the elderly and terminally ill. Estimates put the total cost of around $32 trillion.

Following a Democratic primary debate in 2016, Warren Gunnels, an aide to Sanders, confirmed that millions of illegal immigrants would be covered under the senator's plan.

"It would cover everyone, including aspiring Americans," said Gunnels at the time.

In March, Gillibrand said she supported expanding Social Security benefits to illegal immigrants.

"If you are in this country now you must have the right to pay into Social Security, to pay your taxes, to pay into the local school system and to have a pathway to citizenship. That must happen," she said in Davenport, Iowa.