Throughout the Hungarian Middle Ages the valleys of the Mecsek became more densely populated, providing raw materials for the thriving episcopal city of Pécs. The castles of Szászvár, Márévár and Kantavár were built in the era as residencies of nobles or the Church. The Order of Saint Paul the First Hermit partially stemmed from the hermit communities of the Mecsek, whom the Bishop of Pécs founded a monastery at Jakab-hegy in 1225. The significant Pécsvárad Abbey also controlled substantial areas in the region.