He was the eyes and ears of Elizabeth I, the loyal spymaster and ruthless counterterror chief: Sir Francis Walsingham was the man who knew everything. Or not quite everything, it seems. Certainly not that his portrait was secretly painted over an overtly Roman Catholic image of the holy Virgin and Child.

“He would not have been delighted,” speculated Dr Tarnya Cooper, standing in front of the remarkable new discovery going on show at the National Portrait Gallery. “You do wonder if the artist might be enjoying a private joke."

The gallery on Thursday opened a display showing x-rays of devotional paintings it has discovered underneath its portraits of two key Tudor statesmen. As well as a Virgin and Child under Walsingham, researchers found A Flagellation of Christ under the Queen’s lord treasurer Thomas Sackville.

The Walsingham portrait dates from the 1580s when Protestant England was isolated and supporting the war in the Netherlands against the Spanish.

“The Catholics are the absolute enemy at this period so the idea that you’ve got this wonderful devotional image underneath your portrait would probably be rather horrifying to him,” Cooper, the NPG’s chief curator, said.

It was a surprise finding. “There is not very much that Walsingham does not know about of what’s going on in courts across Europe, he has a huge network of informers, is an incredibly wily man and is someone with a public reputation. For somebody who is not wonderfully keen on Walsingham this would be a clever way of getting at him."

The NPG believes it cannot be accidental that after x-raying more than 120 Tudor portraits and mostly finding nothing, it found an image so emblematic of Roman Catholicism under Walsingham. “It is intriguing that it is under the spymaster-general,” said Cooper.

Walsingham, Elizabeth’s secretary of state from 1573 until his death in 1590, was for a long time portrayed as something of a historical villain but, like Henry VIII’s enforcer, Thomas Cromwell, he has had a somewhat rehabilitated reputation. Yes he was ruthless, yes plotters - real and imagined - were tortured and executed; but England was at war and there were assassins who wanted to kill the Queen. Add to that how impossible the Queen was to work for and he could be said to have done a very good job.

The Walsingham and Sackville discoveries have come to light as part of a five-year research project, called Making Art in Tudor Britain, in which the NPG is examining all of its 16th and 17th century portraits with technology that includes x-ray, infrared reflectography and dendrochronology (tree-ring) analysis. That means painstakingly working through 120 pictures, many of them in storage.

The research project’s curator, Charlotte Bolland, said they were “amazed, astonished” by the discoveries. She recalled the day they looked at x-rays of the Sackville painting, a work that dates from 1601. “It was very exciting, we were all huddled round the lightbox and we could see a loincloth and then a little foot and then some figures.” Further examination and research revealed they were looking at a version of a famous mural altarpiece of The Flagellation of Christ by Sebastiano del Piombo that resides in the Borgherini Chapel in Rome.

Whatever the motives of the still unknown artists, both works are excellent examples of Tudor recycling of wooden panels, perhaps because the original paintings were not sold.

“Obviously we’ve bought the portrait as Sackville and it is important to us as Sackville but somewhere underneath there is an Italian-inspired image of the Flagellation, which was really, really surprising for us,” said Cooper.

“What would be lovely is to recover the whole image underneath and we hope that technology will develop to allow us to do that.”

In the meantime, scientists are coming from Italy this month to carry out further hyperspectral infrared tests on the work.

For the NPG, the research project is throwing up a large amount of new information which will be published in due course, not least shedding fresh light on English artistic practice in the 16th century. Cooper said: “If you go to any bookshop you’ll find quite a lot on 16th century Italian or Dutch painting but not much on artistic practice in Britain. “We wanted to know more about our collection because not much had been done since 1969 and of course technology has changed so much.”

The Walsingham and Sackville discoveries are a surprise, but they are part of a recent tradition of art experts using new technologies to find the unexpected. Last year, an x-ray proved that Still Life with Meadow Flowers and Roses, in the Kröller-Müller museum in Otterlo, central Netherlands, which had been attributed to Van Gogh and then unattributed, was in fact painted by the tormented Dutch impressionist all along, because they found the artist’s original painting of two wrestlers underneath.

In 2011, the Rijksmuseum in Amsterdam found a hidden Goya painting of a French general under the artist’s painting of a Spanish judge, Portrait Of Don Ramon Satue, with experts believing he painted over it for political reasons.

Going further back, the Washington County Museum of Fine Arts made a surprising discovery under its 16th century Gerolamo Bassano painting called The Sepulchre. When it was x-rayed by Washington county hospital, researchers discovered a detailed image of a man dressed in late Renaissance clothing with his hands clasped at his waist.

Soon the Sackville and Walsingham works will be joined at the NPG display by another new discovery about a portrait, wrongly said to have been of theologian Richard Hooker, that was given to the gallery in the late nineteenth century. On the back of it is a religious work which researchers now believe is not recycling but is in fact the part of the wing of an altarpiece with one painting being the front half of a door which opens to reveal the other. “It is an oddity in our collection,” said Cooper. “We would love to discover the other door.”

• Hidden: Unseen Paintings Beneath Tudor Portraits is at the National Portrait Gallery, London, until 2 June.