The law, which is largely a formalization of the current practice, stipulates that clandestine immigrants and rejected asylum seekers can only receive emergency medical care if they pay for it themselves.
The parliament voted 265-33 in favour of the proposal, with the left-wing Green Party and Left Party voting against it on humanitarian grounds.
The vote was postponed by a day to allow for an extended debate.
The government plans to create a commission later this year to examine whether some groups within the categories of people who will not receive subsidized health care should be entitled to it.
All parties in parliament are, for instance, in favour of giving clandestine immigrant children the right to subsidized medical care.