José María Rivas was born in Cojutepeque. His father was a military officer and politician.
Rivas resisted efforts by President Gerardo Barrios to conscript soldiers from the Cuscatlán Department where he was from. During the War of 1863 against Guatemala and Salvadoran rebels, Barrios appointed Rivas as the governor of Cuscatlán to win him over as an ally. Despite this, Rivas turned against Barrios and joined the rebels during the Siege of San Salvador. After the war, President Francisco Dueñas reaffirmed Rivas' appointment as governor of Cuscatlán.
After Dueñas was overthrown by Marshal González, González appointed Rivas again as governor of Cuscatlán. President Rafael Zaldívar again appointed Rivas as governor of Cuscatlán in the late 1870s. In 1885, Rivas joined a revolution against Zaldívar led by Divisional General Francisco Menéndez, during which Rivas captured Cojutepeque and defeated both pro-government and Nicaraguan forces. Menéndez appointed Rivas as governor of Cuscatlán, but Rivas revolted against Menéndez in 1888 when he was not appointed as vice president. The rebellion failed and Rivas was pardoned, but he attempted another rebellion in 1890 that also failed, after which Rivas fled El Salvador to Honduras.
Menéndez was overthrown by General Carlos Ezeta later in 1890. Carlos feared that his former ally General Horacio Villavicencio would launch an invasion from Guatemala and Rivas offered to defend Carlos if he reinstated him as governor of Cuscatlán. Carlos accepted and commanded 3,000 soldiers towards Guatemala, but in Nueva San Salvador, Rivas rebelled against Carlos and occupied San Salvador. Carlos' brother, General Antonio Ezeta, led an army to San Salvador and defeated Rivas. There, Antonio had Rivas executed.