The subject is a comparatively rare one, which occurs occasionally in the Netherlands and Spain in the 17th century. It derived from the Gospel episode of the return of Jesus from the Temple with Mary and Saint Joseph, the three figures forming an 'earthly' trinity with the dove and the figure of God the Father representing the 'heavenly' Trinity.
According to Murillo's biographer, Palomino (1724), the painting was executed for Cádiz and belonged to a Marqués del Pedroso. Painted in Murillo's latest and most confident manner, it probably dates from about 1681/2, when the artist was working for the Capuchin church in Cádiz.
The model for the Virgin appears in other works by the artist.