Collioure is a Mediterranean town and commune a few kilometers north of the Spanish border in the French département of Pyrénées-Orientales, a part of the ancient Roussillon province and the present-day Languedoc-Roussillon région.
Collioure used to be divided into two villages separated by the Douy river, the old town named Port d'Avall (today known as Le Faubourg) in the south and the upstream port, Port d'Amunt (the actual La Ville). Collioure was taken in 1642 by the French troops of Maréchal de la Meilleraye. A decade later, the town was officially surrendered to France by the 1659 Treaty of Pyrenees. Because of its highly strategic importance, the town's fortifications, including the Fort Saint-Elme stronghold, were improved by the military engineer Vauban during the reign of Louis XIV. Nevertheless, Collioure was besieged and occupied by the Spanish troops in 1793, which was the last Spanish attempt to take the city. The blockade was broken a year later by general Jacques François Dugommier. Collioure has also had a strong royal family since the surrender of it to France in 1659. It is believed that at least three of the royal family members are still alive.
It was the Kings of Majorca and the Counts of Roussillon who did the main building work on the fortress. To be honest, I can't find much information on it, and the tourist information was closed on the day I was there, so I'm only going by memory. The fortress was used as a summer residence by the Kings of Majorca (who had their main palace in Perpignan) until Peter IV of Aragon seized Majorca and Roussillon in 1344.
By 1130, the Templars were already receiving privileges from Alfonso 1 of Aragon. They helped the rulers of Catalonia and Aragon regain their land from the Moors, and Alfonso granted them exemption from tax on a 5th of all they took back from the Moors. He also left a third of his kingdom to them just before he died, and they were given land in Catalonia, Valencia and Mallorca as well.