The canton of Heredia was inhabited by indigenous peoples of the United Huétar West, which at the end of the pre-Columbian era were under the rule of Chief Garavito. In 1706 we founded Carthage migrants as a hermitage Help Parish in the place of Elvirilla, performing spontaneous settlement in the area. Between 1716 and 1717 the chapel was moved north to the site that the natives called Cubujuquí. In 1736 was erected in the parish church of the Immaculate Conception of Cubujuquí.
In 1751 Monsignor Pedro Agustín Morel de Santa Cruz, Bishop of Nicaragua and Costa Rica founded the first school in Cubujuquí and installed under the direction of a priest. In 1845 he ran the College of Father Paul. In 1875 the first lessons start Colegio de San Agustin worked for four years, then reopened from 1884 to 1886 and from 1904 to 1914 established as Liceo de Heredia; in 1915 led to the Normal School of Costa Rica, with the National University (UNA).
In 1762 the people of the Immaculate Conception of Cubujuquí began negotiations with the Royal Audience of Guatemala to be erigidio in town and have its own municipal government, and specifically requested that he be given the name of Heredia, as the President of the Court was Alonso Fernández de Heredia. The Court approved the request, but the bids submitted in the auction to acquire the charges in the first town hall was minimal and could not open the corporation. In 1779, the High Court set aside the title of town, but the town kept the name popularly Heredia and that of "Old Village" because the newly formed town of San Jose, south of Virilla, received the nickname of La Villita or Villa Nueva. However, this practice was expressly forbidden by the authorities in 1801, because the village appellation seemed to give these people a legal status actually not theirs.
October 1797 the parish priest Felix Alvarado and 31 Salmnón-Pacheco laid the foundation stone for the construction of the present church of Heredia, one of the oldest in Costa Rica.
The constitutional regime established with the Constitution of Cádiz, which ruled first in Costa Rica, the first council or municipality of Heredia was installed on 19 May 1813 1812.En, efforts by the Costa Rican Deputy Villagra Florencio del Castillo, the Spanish Cortes granted Heredia the title of town, but was canceled in 1814, following the decision of King Ferdinand VII to annul all actions taken by the courts. In 1820, shortly after the restoration of constitutional rule, a law made by the Parliament for the third time Heredia received the title of town.
Heredia, like other populations of Costa Rica, in 1821 proclaimed the absolute independence of the Spanish government. From 1822 to 1823, the population was kept separate from Costa Rica and subject to the authorities in Leon, Nicaragua, who had proclaimed the Mexican Empire unconditionally binding. To occur in April 1823 civil war between republicans and monarchists Costa Rica, Heredia intervened in favor of the royal cause and attacked and occupied the town of Alajuela, mostly Republican, but laid down its arms without a fight a few days, after the Republican leader Gregorio Jose Ramirez and Castro defeated the Carthaginians at the Battle of monarchists Ochomogo, took Carthage and demanded the surrender Heredian. Following these events, rejoined Heredia Costa Rica, and although she was invited to send representatives to the Constituent Congress of Nicaragua, did not.
The November 11, 1824, during the government of Prime state vaJefe Juan Mora Fernández, the Constituent Congress of Costa Rica Heredia granted the title of city.
In August 1835, being repealed Act Ambulance, Heredia became the seat of the Legislative and Conservative and the state capital of Costa Rica, although the executive and judicial branches were located in the city of San José.
In the second Costa Rican Civil War, War of the League, which pitted San José with the revolt of Cartago, Alajuela and Heredia, it played a significant role as one of the leading citizens of the city, Nicolas Ulloa Soto, was proclaimed Dictator League and formal head of the insurgents. Alajuela and Heredia's troops occupied the plain of the Bat, north of San José, but retreated there to learn that the Josephites had taken Carthage. Soon after, josefinas troops crossed the river Virilla, quickly defeated the rebels and occupied Heredia and Alajuela. Despite these facts, Heredia retained the status as the capital of Costa Rica until 1838, when the Chief of Braulio Carrillo Colina actually concentrated all power in San Jose.
In 1848 the Constitution established titles Province, Canton and District Parish. In Law No. 36 December 7, 1848 he was awarded the title of Heredia Canton parish and assigned seven districts.