Get ready to spend more paper — for paper or plastic.

The New York City Council Thursday passed legislation imposing a minimum nickel fee on every new disposable bag.

Starting Oct. 1, certain stores would be required to charge shoppers under the bill, approved by a 28-20 vote, one of the tightest margins in years. Mayor Bill de Blasio said afterward he would sign the bill into law.

EditorialEditorial: Go for NY State ban on disposable bags

A store would keep the 5-cent fee and could charge more if desired. The fee would apply to paper and plastic bags alike. After a grace period ends April 1, 2017, stores would face fines of $250 for the first violation and $500 for a subsequent violation.

“It works by irritating us into changing our behavior and remembering to bring reusable bags,” said Council member Brad Lander (D-Brooklyn), a prime sponsor of the “Bring Your Own Bag” bill, Introduction 209-A.

The bill contains exceptions, such as for take-out and delivery food, produce, meats and prescription-drug purchases.

advertisement | advertise on newsday

Efforts to regulate the estimated 9.37 billion disposable bags used annually in New York City had languished in the council for years. To attract more support, bill sponsors reduced the proposed fee, originally a dime. A news release distributed by the speaker’s office said supporters hope the legislation would defray the estimated $12.5 million annual cost of hauling 91,000 tons of plastic and paper bags to landfills.

Debate over the bill lasted hours Thursday, late into the afternoon: Might city shoppers be encouraged to patronize nearby neighborhoods on Long Island and in New Jersey that don’t charge the fee? How many bags do shoppers need during a grocery trip? Even bags’ wholesale cost — a penny? a nickel? a quarter? — was in dispute.

Council member Eric Ulrich of (R-Queens) worried about pet owners picking up after their dogs in an era of 5-cent bags.

“His dog-poop argument is dog poop!” Council member Antonio Reynoso (D-Brooklyn) said in response.

Council member James Vacca, a Bronx Democrat who voted against the bill, said: “This is another needed expense that we need like a hole in the head.”

Get the Newsday Now newsletter!

The best of Newsday every day in your inbox.

He added: “Just when you think that they’ve taxed everything in sight, you now have learned that there’s something else that was not taxed that will be taxed.”

Bag regulation has been imposed in cities across the country, such as Washington, D.C., and San Francisco, but New York City would be the largest municipality to do so, said Phil Rozenski of the American Progressive Bag Alliance, a plastic-bag trade group. The group hired lobbying and publicist firms to defeat the bill.

Rozenski disputed whether the measure would do much good. He pointed to a finding of the American Plastics Council that more than 90 percent of bags are reused, such as for trash.

Rozenski said his group is considering suing to stop the bill.

Cecil Yearwood, 44, a coffee-company manager who lives in Brooklyn’s Flatbush neighborhood, said he hopes the law would make people more conscious of the environment.

advertisement | advertise on newsday

“It’s our world that we live in and we need to protect it for our children and our children and our children’s children,” Yearwood said.

Asked at a news conference before the vote about a total plastic-ban ban, Council Speaker Melissa Mark-Viverito (D-Manhattan) would not rule out a future law prohibiting the bags entirely.