The Castle of Tàrrega (cat. El Castell de Tàrrega) is a building in Tàrrega (Urgell), declared cultural asset of national interest. It is located on a small hill in the southwestern part of the city. This construction is the founding origin of what is known as the medieval town of Tàrrega, located at crossroads from Barcelona, Tarragona and Balaguer, a strategic point within the territory.

The town of Tàrrega raised around its castle, possibly of Arab origin. The castle was an advanced border line, since the Saracens still occupied the counties of La Noguera and El Segrià. The castle was conquered by Count Ramon Berenguer I of Barcelona, who in 1056 gave it, in an engagement to his wife Almodis, in timeless allod. Therefore the castle became an exclusive jurisdiction. In 1058, the counts made an agreement with Ricard Altemir for ‘ipso castro de Tarrega’, which put Altemir in charge of the reconstruction and defense of the fortress and the castlania. In 1069, it was entrusted to Miró Ricolf of Pinós, as together with Pere Udalard they created a small army of twenty men.

Tàrrega was an advanced place in the Osona county for its time. In 1076, the castle was inherited by Ramon Berenguer II, who in 1078 gave the brothers Arnau and Guillem Guadall and their successors, the town, the castle and the Tàrrega district with all its rights and belongings in perpetuity.

From the 12th century a well-defined feudal pyramid was formed between the various castellans who held the castle all at the same time, and who often abused the collection of tithes from the population. In the 12th and 13th centuries the Pinós figured as the head owners with the Peramola as the seconds, however the Santafé and the Torroja were also documented. In 1217, Agnès de Torroja married Ramon Folc IV de Cardona, who joined the feudal pyramid of Tàrrega in a third step. The complex was sold to Arnau Sort who, in 1262, ordered his part to be sold to Guerau d’Aguiló, lord of Talavera. Until the middle of the 13th century, the Granyena were in charge and until the first decades of the 14th century it was the castellan Guillem Rufaca and his descendants. Other lineages that shared the complex were Oluja, Anguera, Montserrat and Clariana. In many cases, they only rented it, without actually living in Tàrrega.

The castle of Tàrrega remained under the dominion of the monarchy despite the fragmentation of powers and interests of the various owners. In 1242, King Jaume I granted the statutes and prescribed the customs by which the town, the castle and its terrains were to be governed. In the middle of the 14th century, under Peter III, the walls and streets of the castle and the town, affected by the successive wars that followed the Principality, were restored. The castle lost its defensive function during the 17th century and recovered it promptly in the 19th century, during the Carlist wars.

In 1984, Tàrrega’s Town Hall bought the ruins of the old castle. The archaeological excavations carried out in the castle after its acquisition enabled the documentation of various elements of the castle. At some point after the 15th century works are documented, at the same time the strong wall of southern enclosure was built, which followed the amortization of the cistern, dated between the 14th and 15th centuries. The construction of the walls of the 18th-19th centuries, linked to the Carlist Wars and the subsequent uses of the castle, is also documented.

The complex is in a very bad state of conservation due to the numerous transformations over time and the neglect suffered after its abandonment. The oldest elements of the castle are the rooms located in the southeast sector, datable between the 11th and 12th centuries, and a cistern with a well that occupies a good part of the bottom platform of the castle. The cistern is 4.5 m deep, 8 m wide and 12 m long, dated around the 13th century. The best conserved structure is the southern wall from the 15th century, with a width of 3.5 m and built with well-spaced blocks tied with mortar. The upper part of this wall, together with the other walls of the enclosure, are the work of the 19th century. The interior space of the castle maintains a large courtyard, surrounded by its annexes.