The National Militia () in Spain was a citizen-organized quasi-military force comparable to the National Guard that arose in France during the French Revolution.

Spain's National Militia has its origin in the civic military defense groups formed in the War of the Spanish Succession (1701–1714), but came to full fruition during the Peninsular War (1808–1814), which is viewed in Spain as a war of independence against Napoleonic France. The Spanish army had been destroyed, but new forces were established at the municipal and provincial level, who fought against both France and against certain remnants of feudalism that remained in Spain.

It was repeatedly dissolved and restored throughout the 19th century.

Peninsular War

The Spanish Constitution of 1812, adopted at Cádiz while much of the country was still under French control, recognized these groups under the name of milicias nacionales as part of the country's military forces, together with the regular troops. At the same time, this legal recognition implied at least the formal end of their status as voluntary organizations armed by distinct local or provincial government entities, merging them officially into a single body. In 1814 a regulation was put into effect specifying the duty of all citizens to serve if called upon, and regulating the militia. In summary, the National Militia was distinct from the regular army and was divided into infantry and cavalry. Officers were elected by their own troops. The militia was composed of citizens between the ages of 30 and 50; 30 citizens were obliged to serve out of every 1,300 in population. They performed tasks related to security, order, and peace within the borders of Spain.

The militia supported and was supported by the patriotic, but also liberal movement unleashed by the Peninsular War. Consequently, when the restoration brought the absolutist Ferdinand VII to power in 1814, the Cádiz constitution was abrogated and the militia was dissolved. 

Much to the displeasure of the king, the Liberal Triennium of 1820–1823 reconstituted the National Militia, which fought against the absolutist uprisings within the peninsula. The end of the Triennium was, once again, the end of the Militia. It was replaced by a different militia known as the Royalist Volunteers (.

Regency
The regency of Maria Christina of the Two Sicilies created a new force in 1834, the "Urban Militia", (). After the Mutiny of La Granja in 1836 obliged the regent to restore the Constitution of 1812, the National Militia was once again established.

The new officers of Maria Christina's army, especially Leopoldo O'Donnell and Baldomero Espartero, who, in 1833, had supported the cause of the three-year-old Queen Isabella II against the claims of the Infante Carlos, Count of Molina, took a strong ascendency over the National Militia, so that with their collaboration the Militia fought in the First Carlist War on the side of Isabella II and received their first standards as recognition of actions performed during this conflict. Nonetheless, the forces that supported Isabella II were plagued by conflicts with one another. On one side were the forces of conservative liberalism known as the doceañistas, arrayed around the Moderate Party and Maria Christina; on the other the radical liberalism of the exaltados or veinteañistas arrayed around the Progressive Party and the National Militia. 

The militia participated in the Mutiny of La Granja, the fall of Maria Christina and the rise of 
Baldomero Espartero, against the uprisings of the Moderates (especially the Revolution of 1841 promoted by Maria Christina) and against the establishment of the Década moderada in 1843, which brought Ramón María Narváez and the Moderates to power. Narváez dissolved the Militia, and shortly thereafter assigned their duties to a newly created Civil Guard (), which survives to this day. The National Militia was briefly reestablished during the Bienio Progresista in the 1850s, under Espartero. However, when O'Donnell and the Liberal Union dispatched Espartero two years later, the Militia was again dissolved.

First Spanish Republic
The National Militia as such was formally reestablished by a presidential decree of Emilio Castelar during the First Spanish Republic, but once again, and definitively, dissolved by Cánovas del Castillo in 1876.

References
 

Military history of Spain
Militias in Europe