A judge said an NYPD cop is such a big liar that there was no choice but to toss out evidence that could have put a suspected drug dealer behind bars for life.

Bronx officer Luis Rios’ alleged on-the-job tall tales were compounded by his lying about them in court, and cost federal prosecutors all the drug evidence that the cop collected against an armed suspect — 16 baggies of cocaine during a strip search.

The ruling by federal Judge Paul Engelmayer — made after Rios even lied to him under oath about having previously lied — effectively kills the drug rap against Christian Gonzalez that carried up to 20 years in prison.

And it could put the ­kibosh on a federal gun charge against Gonzalez for use “of a firearm in furtherance of drug trafficking,” which carried the potential of life behind bars, a legal expert said.

The expert said the gun case would likely be kicked down to state prosecutors and carry a charge with far less jail time.

Rios, a 49th Precinct officer with 20 years on the force, has pleaded guilty to the NYPD’s Internal Affairs Bureau three times in the past for lying.

In 2009, he falsely reported that a fellow cop drunkenly smashed into him on a scooter in the 114th Precinct in Queens.

Rios’ tale “was vivid and detailed; he asserted, for example, that [the officer] hit him so hard that he went flying into the air,’’ Engelmayer noted in his ruling Friday.

But Rios later admitted to IAB that he’d lied about the incident — and also made up harassment complaints against other cops. He later lied to IAB about it all.

But he only made matters worse when he lied to Engelmayer about the untruths.

In a March hearing, he told the judge that he never said the scooter cop was drunk — and Gonzalez’s lawyers promptly played a recording of him telling IAB that the officer smelled like booze.

“This series of answers was incredible,’’ the judge wrote, referring to Rios’ false denials.

“The court is therefore left with no confidence that any part of Officer Rios’ testimony can be ­assumed as true.”

The NYPD had previously docked him 25 vacation days for lying to IAB.

The department also put him on “dismissal probation’’ in 2012 for the lies, meaning he could have been fired for any reason during that year.

He also was disciplined for falling asleep on duty outside the United Nations and for misrepresenting his outside employment.

An NYPD rep said the judge’s decision “does not necessarily indicate any grounds for action by the Police Department.

Additional reporting by Shawn Cohen