Back in the 11th century, Pier Damiani, a Doctor of the Church, wrote a treatise called De laude flagellorum (In praise of flagellation), establishing the concept that participating in Christ's sufferings promised a share of his glory in paradise. Both founders of the great 13th century preaching orders, SS. Francis and Dominic, were keen practitioners, Francis wanting to keep 'Brother Donkey' (the body) in line; Dominic went a step further: 'three times every night he would 'whip himself with an iron chain: once for himself, once for the sinners in the world, and one for the sinners who are suffering in purgatory.'
In Italy, in particular, a number of aesthetic minded penitential brotherhoods known as battuti sprung up. Santa Maria della Vita was built in 1260 by Riniero Barcobini Fasani of Perugia, the founder of one of these, the ConfraternitĂ dei Battuti Bianchi (the 'Brotherhood of the White-robed Whipped Ones'). Next to the church, the brotherhood set up a hospital, the Ospedale della Vita e della Morte ('of life and death', not really a name to boost the confidence of patients) to treat the poor and shelter passing pilgrims.
Image by Sailko, GNU Creative Commons License