The insurgent forces commanded by Valerio Trujano and Miguel Bravo had joined together with those of the priest, Father Mendoza at the beginning of March 1812 at Tamazulapan, Oaxaca.
The insurgent attackers, who initially believed their assault to be a complete success, were turned back and obliged to retreat once they reached the fierce Spanish resistance in the city center.
He was quickly aided by more royalist troops under the command of José María de Régules Villasante on 5 April 1812 beginning the siege.
Five days after their arrival at Huajuapan, the royalist troops opened fire on the city, unleashing all their firepower on the rebel defenses.
The Spanish royalists decided to withdraw from the battle, leaving behind 30 cannons, over 1,000 muskets, horses, various supplies and over 400 dead.
On the night of 23 July, the bishop of the town together with the bulk of the clergy from the diocese, celebrates a mass in the atrium of the central cathedral to give thanks for the heroic defense of the city.