The government had originally intended to create new regulations for vending machines, and impose a ban only if that failed to prevent cigarettes from being sold to children. But Labour MPs added a late amendment to ban them outright.
Health Minister Gillian Merron said she hoped that the ban on machines, through which only 2% of tobacco sales are made, would dissuade young people from smoking.
The ban brought the UK into line with 16 other EU countries, she added.
The government is set to produce guidance on the regulations in the new year.