If you’re not old enough to drink legally in New York City, you soon won’t be old enough to buy smokes legally.

Mayor Bloomberg on Tuesday signed a new law raising the age for purchasing cigarettes from 18 to 21, the same as the minimum drinking age.

The measure takes effect in 180 days.

“This law will be replicated, I hope, throughout the world,” said City Councilman Jim Gennaro (D-Queens), the bill’s sponsor, who lost his mother and father-in-law to lung cancer.

New York is the first large urban area to bar young adults from buying regular and e-cigarettes, though it is not illegal to possess them.

“This is an issue of whether we are going to kill people,” Bloomberg said of the new law, adding that anyone who fights it by using an economic argument “really ought to look in the mirror and be ashamed.”

Convenience-store owners have argued that the law will simply encourage teens to shift to the black market and deprive the city of tax revenue.