MEXICO CITY — A brawl on Thursday among rival gangs in a prison in the Mexican resort city of Acapulco left at least 28 people dead and three wounded, the authorities said.

The violence began before dawn, and by the time security forces regained control of the prison several hours later, corpses were scattered around two cellblocks, including in a kitchen, a yard and an area reserved for conjugal visits, according to a statement from Roberto Álvarez Heredia, security spokesman for Guerrero, a state on Mexico’s Pacific Coast.

The military, along with the state and federal police, were called in to help re-establish order. The state’s governor ordered an investigation, Mr. Álvarez said, adding that the inquiry would include “all the public officials of the penitentiary system.”

It was just the latest violent episode in Mexico over the past several days to end in large body counts, and the killings added to the country’s soaring homicide tally. At its current rate, Mexico is on pace to have its deadliest year in recent history.