The Welsh Government last night said the ban would cut off a source of tobacco teenagers.
One in 10 regular smokers aged 11 to 15, say they buy their cigarettes from vending machines.
Health Minister Lesley Griffiths said: “A voluntary code has not been effective in sufficiently restricting young people’s access to tobacco from vending machines.”
Carole Morgan-Jones, chief executive of Ash Wales, said: “These regulations will protect children from having easy and illegal access to cigarettes.
“It’s an an integral part of a comprehensive strategy to tackle the harm that tobacco causes to Welsh communities.”
Dr Richard Lewis, British Medical Association Welsh Secretary, said: “Displaying packets of cigarettes in shops and in vending machines contribute to normalising the habit and encourage the onset of smoking.”