The castle of Penyafort (cat. El castell de Penyafort) is located to the south of Santa Margarida and the Monks, near the river Foix and close to a series of industries. It is a complex formed by the remains of the old fortified village of Penyafort (circular tower, parts of a curtain wall), a convent and a church. Traditionally considered to be the birthplace of Saint Ramon de Penyafort (1185-1275), Dominican and canonist, doctorate in jurisprudence from Bologna and councilor of James I, canonized in 1601. This space, of different architectural stages, is the access door to the Foix Natural Park.

The castle of Penyafort, possibly built in the 11th century, was originally formed by a tower and a square house, as were the castles of Moja (981) and Canyelles (992). These small castles had a subsidiary and double function: they were protective centers for the peasants who colonized the new zones conquered by the Saracens and at the same time served as advances to prevent attacks on the castle of Olèrdola, built between 929 and 930 in a place that is strategically very well located and that exerted its dominion on border lands extending for about 250 km². The colonization policy driven by the counts of Barcelona promoted settlement by Christian settlers from the largest territory of the county.

The castle of Penyafort, initially, was ruled by a Castellan appointed and depending on the Lord of Olèrdola. Later on, it became independent, and in the 12th century the tower of Penyafort was already cited to be under the dominion of the lords of Penyafort, under which it remained until the middle of the 14th century. It is considered that one of the members of this family, born in 1185 in this place, was Saint Raymond de Penyafort, who in 1229 preached a Crusade against the Muslims on behalf of the pope.

Bernat de Penyafort, grandson of Pere de Penyafort, was its lord in 1337. In 1356, Arnau de Montoliu, the last descendant of the lineage, sold the house to Pere de Crebeyno. There is no information from the succeeding years but it is known that in 1405 it was half demolished. In 1586, the Diputació of the General of Catalonia took its properties away from Pere and Pau Riu.

Fifteen years later, Martí Joan d’Espuny de Argençola, married to Agnès Espuny and Alemany, bought it at a public auction, becoming known as the lord of Penyafort and Pacs since then. In 1602 he obtained the Authorization to build a chapel dedicated to St. Ramon de Penyafort, sanctified the year before by Pope Clement VIII. Martí Joan d’Espuny in 1603 donated the tower and annexed dependencies to the order of the Dominicans.

During the Peninsular War, this convent was besieged by the French. In 1836, (Confiscation of Mendizábal), under the reign of Isabella II of Spain, the forced sale of ecclesiastical goods was decreed, in which they became the assets of the State in order to be privatized through auctions. In 1851, Miquel Puig purchased from the State the property of the convent. Miquel Puig was succeeded by his son Josep Puig Llagostera, married to Rosa Amat. When he died in 1879, his wife resided in the convent.

During the Spanish Civil War, the church was sieged and adapted as a prison. The owners and sharecropping tenants continued to live in the residential mansion. James R. Halloway, in 1959, together with some partners, restored the rooms in order to turn it to a hotel. In 1966 it was the property of Dimitri Nicholas. In 1971, Martín Fainberg and Oliver Johnson acquired it for wine business. In 2002, the City Council of Santa Margarida and the Monks acquired the convent.

Penyafort Castle is an architectural complex declared Cultural Asset of National Interest (BCIN), which is formed by the medieval tower, a 17th century Dominican convent and a 19th century mansion. The oldest building is the cylindrical tower and some annexed buildings that have undergone many transformations. It was documented for the first time in the 12th century but possibly erected in the 11th century as one of the castles of the Penedès border built after the Al-Mansur raid. The convent dates back to the 17th and 18th centuries, it also has various constructions and extensions that were erected in the 19th century, after confiscation.

The church has a single nave with a barrel vault and lunettes, arches and six side chapels per side. The entry portal is neoclassical, with a pediment broken by a niche.

Coordinates: 41° 18′ 23″ N, 1° 39′ 30″ E