The dramatic picture, The Massacre of the Innocents, by a 17th-century Neopolitan artist in the circle of Francesco de Rosa, called Pacecco - to be sold at Bonhams on 8 July - is likely to go a long way towards solving the restoration problems of the 800-year-old church of St James's, near the village of Dauntsey, Wiltshire.
'It's a miracle,' said the Reverend Derek Ormston. 'We need pounds 80,000 worth of repairs on the roof and gutters. The roof, which has perished, is all slate. You can't put modern cheap tiles on it. You need handmade slate tiles. The longer it is delayed, the more it'll cost.'
The painting, spattered with bat droppings, was spotted by Paul Whitfield, deputy chairman of Bonhams who lives locally.
Andrew McKenzie of Bonhams said that they arrived at the attribution after extensive research, and consultation with leading academics on Italian Baroque painters. He said that the painting shows the inspiration of Caravaggio, the most influential figure on Neopolitan artists of that period. Yet Mr Ormston said that no-one had ever really noticed it: 'The irony is that it shows the slaughter of children and guess where it was hung? In the children's corner of the church. Somebody had a sense of humour.'
Before the church could sell the painting, it had to establish ownership. Mr Ormston said that there is nothing in the records: 'One of the old ladies in the parish remembers a time when it was not there.' He believes that it may have been a gift in 1906, when the church was undergoing renovation, from the art-collecting owner of a nearby manor house. 'No-one's made any claim, so that's it,' he added.
In an ideal world, the sale would raise the funds needed to restore the church's medieval doomboard, depicting The Last Judgement. It is one of only five in the country. Its restoration will cost some pounds 20,000.