It turned out to be a garbage idea.

The MTA has canned its pilot program that removed trash receptacles from subway stations as a way to reduce station littering.

The idea was that, without trash cans, riders would be encouraged to carry their garbage with them, appropriately disposing of their refuse and recyclables at another time and place.

Trash can start track fires, which cause delays. Garbage also helps turn the subway system into cozy digs for rats. But, as it happens, the pilot hasn’t panned out.

“It took the MTA five years, but we are gratified that it recognized the need to end this controversial experiment that showed little to no improvements in riders’ experience,” said New York State Comptroller Thomas DiNapoli, who announced the pilot’s demise in a statement Tuesday.

DiNapoli’s office has been hounding the MTA over the agency’s pilot since its launch at two stations in 2011. After positive early results — fewer rodents and less trash for workers to haul — the MTA eventually expanded the pilot to 39 stations in four boroughs.

In September of last year, however, the agency decided it was time to put the lid on the project and move in a different direction to keep garbage out of the subways.

Beth DeFalco, an MTA spokeswoman, said in a statement that the pilot “wasn’t the most efficient way to clean the stations” and that the agency has found other “highly successful” initiatives.

“One would think that in his position, the comptroller would push for the most efficient and cost-effective method to clean stations — but this just smells like grandstanding,” DeFalco continued.

The MTA removes about 40 tons of trash from the subway system each day from more than 3,500 trash receptacles. The agency has found promise in its recent, multi-pronged approach to cleanliness called “Operation Track Sweep.”

As part of that program, the MTA has more than doubled the number of stations it cleans, from a schedule of 34 stations every two weeks to 94 stations in that time period. It’s also begun testing two new portable track vacuums that can be quickly deployed, put to use and moved around from station to station. Ideally, a fleet of these machines would complement the agency’s vacuum trains and refuse cars.

Adding to its arsenal, the MTA is procuring three new track vacuum trains — those loud, yellow self-propelled work trains that commuters might see crawling past their stations during late nights, sucking up the trash and steel dust along the way.

The agency is also purchasing 27 new refuse cars to aid in securing and transporting the wheeled garbage containers that are collected at subway stations.

DiNapoli seemed more content with these measures.

“Straphangers, who have just been burdened with another fare increase, deserve cleaner stations that are free of rats,” DiNapoli said. “We’re encouraged the agency continues to address cleanliness in other ways.”

At the 39 pilot stations where cans were removed from mezzanines, track fires dropped by 41% after a cleaning blitz this summer, according to the agency.

But looking at data system-wide, it’s unclear if anything can save the subways from their own riders’ filth. In August 2016, before the MTA halted its trash can pilot, track fires caused 801 delays. But in January of this year, the most recent data available, track fire delays nearly doubled to 1,599.

Straphangers appreciated the effort.

“I understand the idea and it was worth a shot,” said Andrew Smith, 25, of Park Slope. “They are trying to think outside the box with it, but people are always going to litter.”