New York State Legislators will be able to keep both their fat raises and outside gigs, an Albany judge ruled Thursday.

It’s the second decision by a state judge knocking down a virtual ban on outside income in separate cases involving different plaintiffs.

The restriction on outside income was part of a deal that paved the way for the raises set last year by an executive and legislative compensation committee appointed by Gov. Andrew Cuomo and the legislature.

The three-year phase-in salary hikes were linked to the restriction that barred senators and assembly members from earning private income that exceeded 15 percent of their legislative salary — beginning in 2020.

Cuomo was a big force behind this committee and championed the ban on outside income to curb conflicts of interest and pay to play politics. He and the legislature okayed the committee during the 2018 budget agreement. The appointees to the panel included state Comptroller Tom DiNapoli, city Comptroller Scott Stringer and former comptrollers Carl McCall and Bill Thompson.

But state Supreme Court Judge Richard Platkin ruled that the pay panel overstepped its authority because the law that created it did not give it the authority to restrict outside income. The law did give it the power to raise salaries, he said.

“There is nothing [in the law]that authorized it to recommend restrictions on outside income and employment that have the force of law. These policy matters remain reserved for the Legislature and the Governor,” he wrote.

“The Court concluded that petitioners have demonstrated their entitlement to a judgement declaring that the Committee’s restrictions on outside income and employment do not have the force of law,” he added.

The suit, brought forward by Assemblyman William Barclay (R-Syracuse), state Sen. Tom O’mara (R-Elmira) and several other Republican pols, is the second of two separate decisions arguing in favor of striking the income limits.

The pay commission bumped the base salary of legislators from $79,500 to $110,000 in January.

That’s set to increase in 2020 to $120,000 and $130,000 in 2021.

It also fast-tracked Cuomo to become the nation’s top-paid governor, increasing his salary to $200,000 this year, then $225,000 in 2020 and $250,000 in 2021.

Raises for the Lieutenant Governor, state Attorney General and state Comptroller were also included in the committee’s report.

Cuomo in June blasted a prior court ruling tossing out the ban on outside income.

While the cases will be appealed, he argued lawmakers ultimately have the power to ban outside income themselves if the courts rule otherwise.

“Worst case scenario, the legislature could pass the bill saying we will ban outside income ourselves. They could say we will ban outside income if the commission holdings are upheld. So that’s all it comes down to is the outside ban, which the legislature has already agreed to the outside ban because they took the raise, right?” said Cuomo.