Parliament in Belgium has passed a bill allowing euthanasia for terminally ill children without any age limit, by 86 votes to 44, with 12 abstentions.
When, as expected, the bill is signed by the king, Belgium will become the first country in the world to remove any age limit on the practice.
It may be requested by terminally ill children who are in great pain and also have parental consent.
Opponents argue children cannot make such a difficult decision.
It is 12 years since Belgium legalised euthanasia for adults.
In the Netherlands, Belgium's northern neighbour, euthanasia is legal for children over the age of 12, if there is parental consent.
Under the Dutch conditions, a patient's request for euthanasia can be fulfilled by a doctor if the request is "voluntary and well-considered" and the patient is suffering unbearably, with no prospect of improvement.
One man in the public gallery of Belgium's parliament shouted "murderers" in French when the vote was passed, Reuters news agency reports.
Supporters of the legislation argue that in practice the law will affect an extremely small number of children, who would probably be in their teens, the BBC's Duncan Crawford reports from Brussels.
The law states a child would have to be terminally ill, face "unbearable physical suffering" and make repeated requests to die - before euthanasia is considered.
Parents, doctors and psychiatrists would have to agree before a decision is made.
Protesters have lobbied politicians against the changes.
Church leaders argued the law is immoral.
"The law says adolescents cannot make important decisions on economic or emotional issues, but suddenly they've become able to decide that someone should make them die," Brussels Archbishop Andre-Joseph Leonard, head of the Catholic Church in Belgium, said at a prayer vigil last week.
Some paediatricians have warned vulnerable children could be put at risk and have questioned whether a child can really be expected to make such a difficult choice.
Last week 160 Belgian paediatricians signed an open letter against the law, claiming that there was no urgent need for it and that modern medicine is capable of alleviating pain.
But opinion polls have suggested broad support for the changes in Belgium, which is mostly Catholic.