Jailed for more than two decades for a crime he did not commit, William Lopez’s brief taste of freedom came to a sudden, tragic end Saturday when he died just days before his $124 million lawsuit for false imprisonment was set to start.

The 55-year-old Bronx man had finally been freed in January 2013, after 23 years behind bars for murder, but a massive asthma attack ended Lopez’s short post-prison life at about 1 a.m. Saturday, his friend told The Post.

Supporters said his unexpected demise denied him the justice he deserved.

“He was always looking forward to being compensated,” said his friend and advocateJeffrey Deskovic, whose foundation worked to free Lopez from prison.

“His life was really robbed from him.”

Lopez had hoped whatever money he got from the suit would help him enjoy a few of the comforts he was denied in prison.

“He wanted to do some domestic travel to other states, and to travel internationally,” Deskovic said. “He wanted to go to college and to go to law school. He wanted to set his wife up in business, and he wanted to be an entrepreneur.”

“It feels great to be back on Earth,’’ Lopez said after his release. “I’m looking forward to restoring my life as best as I can.’’

Lopez was convicted on flimsy evidence for the 1989 shotgun killing of a suspected drug dealer named Elvirn Surria in a Brighton Beach drug den.

The case against him was very weak. One witness gave a description that did not match Lopez’s profile. The other had just finished a crack binge when the murder took place, and later recanted.

“In short, the prosecution’s evidence was flimsy to begin with and has since been reduced to rubble,” federal Judge Nicholas Garaufis wrote before releasing Lopez.

Lawyers and legal staff from the Jeffrey Deskovic Foundation worked for years to free Lopez. Deskovic founded the organization after he was wrongfully convicted of rape and murder but later exonerated.

New DA Kenneth Thompson dropped the appeal by his predecessor, Charles “Joe” Hynes.

In the 20 months of freedom he had after his release, he found some measure of happiness, spending time with his wife, Alice, and rediscovering simple pleasures, such as watching football with friends on Sundays.

Lopez was also trying to rebuild his relationship with his daughter Crystal, who was just 14 months old when Lopez went to prison.

But he struggled financially, and got by, in part, on the generosity of friends. He was demanding $124 million from the city in his federal civil suit, which was supposed to start in Brooklyn on Tuesday.

Lopez’s wife, Alice — who married him while he was in prison — was by his side when he died.

“My brother Bill was greatly bothered by the fact that his life was dramatically impacted by being wrongfully convicted, as well as his knowledge that many other wrongful convictions have taken place without any changes in the system,” said Lopez’s brother Eugene.