The clash began when a group of inmates, fed up with harassment by other prisoners, used homemade knives and picks to attack their rivals starting at about 4:15 a.m. (5:15 a.m. EDT; 0915 GMT) at the La Pila prison in the state capital, according to the state attorney general's office.
Agency spokeswoman Gabriela Gonzalez Chong called the violence a "fight not an uprising" against prison authorities.
San Luis Potosi Gov. Fernando Toranzo told a news conference that 13 inmates had died, and that 22 of the 65 injured were in serious condition.
Toranzo said officials would investigate whether prison authorities played a role in the clash.
Violent disputes between rival cartels and gangs often spill over into Mexico's prisons, where fights, riots and escapes are common.
The National Human Rights Commission reported in 2012 that prisoners, often linked to drug gangs, effectively run the interior of many Mexican prisons.
The Zetas drug gang has been especially active in San Luis Potosi in recent years.
Take ABC13 with you!
Download our free apps for iPhone, iPad, Android and Blackberry devices