The minimum age to purchase cigarettes, e-cigarettes and other tobacco products will be raised to 21 nationwide under the spending bill passed by the Senate on Thursday in a provision aimed at curbing a surge in underage vaping.

If signed into law, the new restriction would take effect immediately. Altria Group Inc. and Reynolds American Inc., the two biggest U.S. cigarette manufacturers, both supported the age restriction, as did Juul Labs Inc., the startup that has been blamed by health officials for the rise in teenage...