A Copiague man was sentenced on Friday to 12 1⁄2 years in prison for masterminding a conspiracy to swindle banks out of $30 million by falsifying mortgage records during a boom in the real estate market more than a decade ago.

Aaron Wider, 51, former head of mortgage bank HTFC Corp. in Garden City, who faced up to 30 years in prison, was found guilty of one count of conspiracy in January of 2016 after a two-week trial in federal court in Central Islip.

Wider was also sentenced to 5 years supervised release, ordered to undergo mental health and drug counseling and make restitution of $22 millions.

Co-defendant Joseph Ferrara Jr., 71, of Long Beach was acquitted of the same charge, conspiracy to commit bank fraud.

There was witness testimony and documentary evidence during the trial that Ferrara and others bought homes, and along with Wider, sold them to a trust that they set up on the same day, then used an inflated assessment to resell them to a new owner at much higher prices, sometimes double the original purchase price.

Then they resold what prosecutors called “toxic” mortgages in the secondary market, pocketing the difference between the real and inflated values, prosecutors said. All of the homes, bought and resold between 2003 and 2008, wound up in foreclosure, leaving banks and investors on the hook for the inflated value after the real estate market crash of 2008.

advertisement | advertise on newsday

Prosecutor Artie McConnell had argued that the paper trail left by Wider and his co-defendants was overwhelming. “The two defendants are guilty on the documents alone,” McConnell told the jury in his summation.

Four other men pleaded guilty in the case.

Deputy Nassau County assessor Eileen Ryan told the jury she flagged transactions with HTFC holding the mortgage. For example, Ferrara bought a Carman Mill Road property in Massapequa for $450,000 on Jan. 31, 2007, and immediately transferred it to a trust bearing the seller’s name. The same day, the property was resold for $800,000, she said.

“On its face, unexplainable,” she said. “There was a whole pocket with that same pattern.”

Wider told Newsday in 2007 when it first reported on the scheme that he bought houses in poor repair, fixed them up and resold them.

“These are houses that were bought in distress,” Wider said at the time. “Since I lend my own money, I can sell the property any price that I want.”