A former NYPD cop got to double-dip on his pension for years when a Long Island village hired him as police commissioner and then changed the job requirements for him, The Post has learned.

Stephen McAllister — an unindicted coconspirator in a hooker-fueled NYPD corruption case set for trial next month — began collecting a $98,000-a-year pension after he retired as an NYPD inspector on Dec. 31, 2009, according to records obtained under the Freedom of Information Law.

The following year, he scored a waiver from the state Civil Service Commission to pocket the pension while also earning $175,000 as commissioner of the 33-member police department in Floral Park, LI.

Under New York’s Retirement and Social Security Law, the waiver can be granted only to fill an “unplanned, unpredictable and unexpected vacancy” or if “there are no available nonretired persons qualified to perform the duties.”

The village told the state it hoped to replace McAllister within two to three years.

At the time he was appointed, the Floral Park Village Code mandated only that the police commissioner be a Nassau County resident and, if hired from the village department, have at least 10 years of law-enforcement experience and hold the rank of sergeant or higher, while anyone from outside the department had to be at least a lieutenant.

But when the village and McAllister sought another two-year pension waiver in 2012, the application said the minimum job requirements were a “Bechelors [sic] Degree and completion of a recognized advanced law enforcement leadership or management training program (Masters Degree and/or Graduation from FBI Academy preferred.)”

McAllister, 56, holds a Bachelor of Science degree from Saint Francis College in Brooklyn, a master’s from John Jay College and a 1993 certificate from the FBI Academy, according to his resume.

The Civil Service Commission approved the 2012 waiver application and another in 2014, which also cited the educational requirements and added at least five years’ “command level” law-enforcement experience.

In 2016, the commission granted McAllister only a five-month waiver and refused to extend it any further.

Following that move, the Village Board voted 4-to-1 in December 2016 to add the education requirements and mandatory “command-level” experience, plus any “other and further qualifications and experience as the Mayor and Board of Trustees may specify via resolution.”

The waiver applications that inflated the job requirements were signed under penalty of perjury by McAllister.

Last year, the village boosted McAllister’s annual salary to $245,000 to compensate him for the loss of his pension payments.

In April, federal prosecutors listed McAllister among a group of current and former NYPD cops in a corruption case involving Mayor de Blasio donors Jeremy Reichberg and Jona Rechnitz.

McAllister has denied any wrongdoing, and was cleared following an internal investigation conducted by Floral Park Village Attorney John Ryan.

Additional reporting by Kevin Sheehan