The city has a long history. In it, the James I of Aragon was trained in its castle by the knights templar, being a strategic spot between Segre and Cinca valleys. Furthermore, the city owned the Aragonese corts in many times.