In Kitchen Scene with the Supper at Emmaus by Diego Velazquez the didactic intent is clear. There she is, a serving girl working away among the shadows of a blankly uninteresting kitchen. We catch her at the very moment that she begins to turn toward the exceptional drama being played out behind her. It is the reappearance of the risen Christ, the moment when Jesus makes himself known to the disciples. The girl is on the very brink of revelation. Her soul as empty as the humble pots and jugs arranged on the table in front of her, empty and ready to be filled with the light of grace. On the other hand, the picture is not without its ambiguities. The girl (and is 'she' even a she?) could be poised on the edge of a revelation, or she could be poised on the brink of nothing at all. Her inner, emotional world is discrete, mysterious and profound. Most importantly, it is closed to us, the viewers. Or only available to us through ambiguous signs, what we can gather from her face, her stance and the guesses we make about her life. Everything about her is uncertain and provisional. Everything, that is, except the limitless depths and range of her emotional world. That we can be certain about. Because what we are looking at is an attempt to depict the inner life that may or may not be concerned with the state of its eternal soul; may not even be in possession of an eternal soul at all.

When you go back much before the early modern period (and, handily, you can crudely date the early modern epoch from just before the age of Velázquez), it is striking how little interest its inhabitants showed in the things that fascinate us. The abyss of the conscious mind, its elusive meanderings and pathetic movements did not really captivate or entrance our far ancestors. For them it was human clay animated by the breath of God, the arduous journey of the soul on the way to either heaven or perdition that provided all the psychological drama they needed. Now, after a few centuries of novels and a hundred years or so of films, after Shakespeare and after Freud, psychological complication and explication is overwhelmingly what we want. It was a movement towards narratives that examined humans as if their psyches stood on their own two feet, without the props of heavenly intervention. This movement towards a secular model of the human mind did not begin, but was accelerated, satisfyingly enough, during the Counter Reformation.

The Counter Reformation was a blast of emotion, a love letter straight from the heart of the Church aimed at its straying inamorata – the capricious, flaky population of Europe and its growing fascination with Protestantism. It was a display of delirious feeling that would entice the floating worshipper back to the one and true religion. Protestantism bleached colour from the world and banished all shadows in order to provide a blank backdrop against which the word of God would ring with the greatest sonority. Catholicism would offer mystery and chiaroscuro, glutted with human feeling, and hope that it proved tempting enough to compete. But the idea of an endlessly complex, shaded human mind was where a new psychological realism would insinuate itself into art and literature and, by degrees, set about extinguishing every spark of divinity that could be found. Diego Rodriguez de Silva y Velázquez, 1599-1660, the painter's painter, the Old Master who moved Manet and Picasso like none of the others could, and the subject of a massive exhibition at the National Gallery in London, was deeply involved.

But the story needs a heavy qualification, and it would be wrong to assume that a painter from one of the most unreservedly Catholic monarchies of Europe was some kind of covert secularist or proto-atheist, or even that he demurred from the respectable intellectual and spiritual positions of his time. But it was a time that had less and less use for a conception of the human mind that was directed by spiritual authority even as it vigorously asserted its religious orthodoxy.

In the kitchen scene the girl's psychological space expands as her theological situation contracts. In this way the biblical drama enacted over her shoulder says both too much and too little – it is too broad and grand to capture her ordinary essence, but neither does it have much to say about what makes her unique: the unmapped continent of her consciousness.

The scene with Christ and the disciples in the background is a foil to the girl's emotional complexity, rather than the other way around. The three figures around the table, telescoped into the background, framed and contained by the window are, by comparison, only hazily sketched in. Compared to our friend in the foreground, they are vague and undynamic and their gestures are wooden and taken from the general stock of religious imagery. The real drama of the picture is going on in the brow of the girl, in the fact that we have caught her in the act of working through a feeling, in her indivisible mental form.

Velázquez did not invent this way of looking at humans, nor was it a part of his local culture. But throughout Europe there was something in the air that was pushing writers and artists in a similar direction. Velásquez was alive at the same time as Shakespeare and Cervantes were writing, though he was still in his teens when both those men died. I'm guessing that he knew nothing of Shakespeare, but must have been aware of the stellar success of Don Quixote. Both writers brought to the page techniques for letting the reader in to the chaotic minds of their creations. Cervantes took his time – almost 800 pages – to show us how the world outside the skull of Quixote could make no impact at all on the delusions of the old man and so mapped, in slightly mad detail, Quixote's psychological biography. Shakespeare, through the use and development of the soliloquy, hit upon a way of retelling a character's drifting thought processes even as the character told them to himself.

In one of Velásquez's early paintings, An Old Woman Cooking Eggs (1618) the two subjects (their faces suggest they are related; mother and son or, perhaps, grandmother and grandson) are caught at a moment of mutual incomprehension. The boy turns his face from his companion as she addresses him. Boy and woman both contain a conscious self that is discrete and hidden from the other. Neither, in fact, are at a great distance from the thinking self that Descartes would describe later in the century: a rational, deliberative being whose relation to the Creator was ambiguous, if it existed at all. And once the rational cat had leapt from the theological bag there was no control over where it would go. The human mind and psyche is an independent, centred cognitive universe; the subject of its own emotional obsession rather than off-site divine invigilation. And, importantly, only intermittently accessible to the equally subtle minds owned by its fellow creatures, rather than a page of holy text to be deciphered by the initiated. It was, therefore, a resource for the writer or painter who wanted to explore its endless range. So it goes with Velázquez and the constantly rationalising characters that persist in appearing among the religious paraphernalia and supernatural preoccupations of his work.

The same effect is carried off with no small amount of brio in Christ in the House of Martha and Mary (1618-1620). Again, the spiritual drama is pushed into the background. It is the two foregrounded figures that command the scene and they do not do so by a display of piety. Rather, it is the momentary and distracted relationship between the older woman and the younger that fascinates. Back in 1620 the contrast between the prosaic kitchen scene and the biblical tableau would have been entirely thrilling, but how immediate and instinctive is our identification with the two women and their fleeting, unspoken exchange.

He painted it when he was just 19 and it was not a great innovation. It came from a recognisable genre: scenes of humble life, often among servants or the poor. In Spain such scenes were known as bodegones, after the bodegas, or wine cellars where they were often set. Wealthy patrons enjoyed seeing pictures of a world that was hidden from them – the private lives of those below them on the social scale. What went on among these people when they were out of sight of their employers provided a peculiar kind of thrill. They mixed puerility and voyeurism, and the paintings often had a moralising edge, with scenes of drunkenness and debauchery among slightly grotesque figures. But Velásquez strips away the moral storyline and replaces it with the mystery of two privately reflecting minds. To what extent this represented a new way of thinking about the self is unclear. But Velásquez's ancestors would not have thought it worth emphasising – this quiet drift and flux of a character's emotional range.

This emphasis on the solitary and secret world was taken to its extreme by Velázquez himself in his very last painting. It is the picture that regularly tops polls of the greatest ever painted. For opacity and obliqueness, it far outstrips the overrated and entirely transparent 'mystery' of the Mona Lisa's smile. It is Las Meninas (1656), and no essay on Velásquez would be complete without a consideration of it, though we can be sure that its celebrated opacity means the last word about it will never be uttered (and it does not feature in the National Gallery show). It was Velázquez' Hamlet and Don Quixote spread over a single canvas. It was where he mingled the minds of his subjects and viewers so successfully that we still have not disentangled it.

The daughter of the Spanish King Philip IV and a selection of her friends, the 'maids of honour' of the title, are arranged in a semi-circle looking out us, the viewers. They stand to one side of a vast canvas with its back towards us. This is being attended to by a handsome and urbane artist – Velásquez himself. He too gazes out of the picture and regards the viewer with relaxed composure. The trick of the painting is that, attached to the far back wall of the room is a mirror. It reflects the faces of the people who are really witnessing the scene, who are invisibly in the position that we, the viewers, occupy: the Queen and King Philip himself. The enduring strangeness of the painting is in the play of glances exchanged between the subjects in the frame and the viewer standing outside it, even though we are not the real viewers but secret substitutes for the royal couple. It is in the endlessly revolving self-observed, observing mind, manipulated and directed by nothing but itself and circumstance.

Toby Saul is a freelance writer. 'Velazquez' is at the National Gallery, 18 October to 21 January