LONDON — Nearly a quarter of a century after 96 Liverpool soccer fans were crushed to death in one of the worst stadium disasters in history, Prime Minister David Cameron formally apologized on Wednesday to the victims’ families, saying their “appalling deaths” were compounded by an attempt by the police, investigators and the news media to depict the victims as hooligans and to blame them for the disaster.

Before a hushed House of Commons, Mr. Cameron said the families had suffered “a double injustice” in the failures of the police, fire officials and other authorities to anticipate the disaster or to contain its scale once it occurred, and in the efforts that followed to cover up police failings by altering witness statements, and to pin responsibility on the victims for their own deaths.

The prime minister’s apology, and the findings of a new inquiry panel on which it was based, marked a stunning reversal in a saga that has been an open wound in Britain since April 15, 1989, when 3,000 Liverpool supporters sought to crowd into standing-room terraces approved for barely half that many at Hillsborough Stadium in Sheffield, 150 miles north of London. All but two of the victims perished that day, many of them within minutes. The last victim remained in a coma until he died in 1993.

It has become known simply as the Hillsborough disaster, a horrifying reference point for sports officials throughout the world, and it has come to symbolize an era of rambunctious British soccer fans and the measures that clubs and the police took to contain them. Fences separated rival fans and prevented them from throwing beer bottles and other missiles onto the field. Clashes with the police were common.