Offenders face a £50 fixed penalty from October in the latest measure to crack down on the harm caused by second-hand smoke, which was approved by AMs.
Smoking is already banned in public service and work vehicles under the legislation passed in 2007. Health Minister Mark Drakeford said smoke posed "a real and substantial threat to children's health".
"Children cannot escape from the toxic chemicals contained in second-hand smoke when travelling in cars," he said. "They often don't have a choice over whether or not they travel in cars and may not feel able to ask an adult to stop smoking."
"As with the existing smoke-free regulations, success will not be based on the number of enforcement actions that are taken but by how behaviour, attitudes and health outcomes change over time."
Currently, people are allowed to smoke in private vehicles but from October it will be banned if anyone under the age of 18 is on board.
While local authorities enforce the existing restrictions on smoking in public places, police will be responsible for action against offenders in private vehicles. A ban on smoking in cars carrying children had already been approved for England.