Another 11 were badly injured in the blaze in the Caballo Blanco (White Horse) bar in Coatzacoalcos, a port city in Veracruz, on Tuesday night.
Survivors said men believed to be gangsters blocked the exits before setting the venue on fire.
Mexican media reported that the bar was peppered with gunfire and Molotov cocktails were thrown inside.
President Andrés Manuel López Obrador said the attack was "shameful", and that an investigation would look into how some of the suspects had recently been freed from custody.
There would be a particular investigation into whether there was any collusion with authorities in connection with their release, he said.
Veracruz regional governor Cuitláhuac García said police were in pursuit of the attackers and vowed that they "will not go unpunished".
Later, he added that one suspect, named Ricardo, was known as "La Loca" - the crazy one - had been released 48 hours after his arrest last month.
Outside the White Horse bar, police and ambulances crowded the street.
One woman standing nearby told a reporter for AFP that she was looking for her son, like many others there. Her son worked as a cleaner at the bar, and she had already searched the local hospitals.
"I just want to know if he's OK," she said.
Officially, prosecutors are only saying that the fire "may have been the result of a vile attack" and are still investigating.
The Veracruz state prosecutor's office denied having ever held the suspect known as Ricardo, saying instead that federal prosecutors had been responsible.
Gang violence, often driven by the drug trade, is not uncommon in Veracruz, one of the most violent regions in Mexico.
It is a popular route for illicit drug shipments or human trafficking destined for the United States - and rival gangs battle for territory and dominance.
Last year, a mass grave of suspected drug cartel victims was found containing the skulls of at least 166 people. In 2017, another mass grave with 250 victims in it was found.