ACAPULCO, Mexico—Fighting erupted between rival gangs inside a state prison Thursday, and 28 inmates were killed and three wounded, officials in the Pacific resort said.

Authorities had initially reported five deaths but later raised the toll as more bodies were found scattered throughout the prison.

Robert Alvarez Heredia, the Guerrero state...