Sant Martí is the current parish church of Riells i Viabrea. The building is of Romanesque origin (12th century), although it was renovated in the 15th century due to damage suffered during the Guerra dels Remences. In the 17th century, the church was enlarged and, in the following century, the adjoining rectory was built. However, during the Guerra Civil of 1936–1939, it again suffered significant damage at the hands of members of revolutionary organisations. In 1956, a restoration project began under the supervision of mossèn Pere Ribot, parish priest and poet. In the 1358 document Constitucions dels castells, the parish of Riells is mentioned as an integral part of the territory of Montsoriu, the principal castle of the Viscountcy of Cabrera.