The valley has been settled since prehistoric times, after which it was occupied by a series of invading tribes until, in the 9th century, the settlement became consolidated with the founding of the monastery of Santa Maria by Count Wilfred the Hairy, as part of a process of repopulation that would lead to the establishment, around the monastery, of what would become the town of Ripoll.
The Benedictine monastery underwent structural modifications between the 9th and 11th centuries when, during the reign of Abbot Oliba, its present distribution was established. The portal, with stone carvings of biblical iconography, was erected in the 12th century.
The monastic dependencies constituted a group of buildings separated from the town by a wall. The Abbot was the feudal lord of much of the territory, and of Ripoll society over which he exercised political, economic, judicial and architectural control, examples of the latter being the building of a canal during the reign of Abbot Arnulf and the permission granted to build a hospital in the 16th century.
It is not surprising, therefore, that from the 13th century onwards, the people of Ripoll attempted, unsuccessfully, to free themselves from feudal oppression. In the 14th century the monastery created the community of clergy of the church of Sant Pere which, over time, became a symbol of the townspeople's opposition to the power of the Abbot. There were also disputes between the two institutions concerning religious supremacy, Sant Pere being the parish of Ripoll, and between the monastery and the people living on its possessions throughout the principality.
These issues exacerbated the decline into which the monastery had fallen, which culminating in the reversals experienced during the first half of the 19th century when the town achieved independence, in 1812, and when, during the First Carlist War (1833–1840), the minister Mendizábal promulgated the expropriation of monastic properties by the State and forced the expulsion of the monks.
The occupation of Ripoll by Carlist troops, in May 1839, led to the destruction of many houses. When the war was over, they were rebuilt with materials found throughout the abandoned monastery, now used as an improvised quarry.
During the second half of the 19th century there were periods during which work was carried out to consolidate the church, and others which accentuated the decline. It was not until 1886 that work commenced on restoring the church and the cloister, a project entrusted to the architect Elies Rogent and conducted under the auspices of the Bishop of Vic, Josep Morgades. Although work would continue into the early years of the 20th century, they were officially declared completed in 1893.