Was Leonardo da Vinci the first surrealist?

In 1910 Freud, the father of psychoanalysis, published his famous work Leonardo da Vinci, A Memory of His Childhood. The most remarkable aspect was not the explicit discussion of sexuality of Leonardo da Vinci, but the fact that Freud labelled the most celebrated artist in history a "failure". Tell that to the crowds jostling for a glimpse of the Mona Lisa. Tell that to Bill Gates, proud owner of the collection of Leonardo's scientific notes, the Codex Leicester. Leonardo today is a symbol of genius and achievement, pure and simple.

It was in the first half of the 20th century that Leonardo was raised above Donatello, Michelangelo and Raphael as the greatest of Renaissance Artists. We are the heirs to this enthusiasm, but we've forgotten what it was about. Most of us slope past the Leonardos in the National Gallery in London unable to look his masterpieces in the eye. This is a terrible shame. Leonardo did not become the modern world's favourite artist because he was perfect, but because he was perceived as imperfect, troubled and tormented. This was why Freud devoted the first ever attempt at a psychoanalytic biography to him. This was why the Surrealists loved him.

When you look at the pages from Leonardo's notebooks in an exhibition of rarely-seen drawings at Christ Church Picture Gallery, Oxford, you start to see this more complex, fragmentary Leonardo. The notebooks seem like an explosion of his psyche in thousands of pages of fantastic drawings and obsessive mirror writing.

Oxford is an appropriate place to encounter the strangeness of Leonardo because that is where his modern cult began. In 1873, undergraduates brought up in the cloistered confines of Victorian society were exposed to the decadent language of Walter Pater, father of the aesthetic movement, in his notorious lecture on Leonardo. For Pater, the whole point of Leonardo is his depravity. He characterises him as a pagan, a disturbed "exquisite", an "enigma" whose work "fascinates, and perhaps half repels". When Pater rhapsodises on the Mona Lisa we really begin to see how flat our language about Leonardo's genius has become: "She is older than the rocks among which she sits: like the vampire, she has been dead many times, and learned the secrets of the grave." Compare this with Bill Gates, who described Leonardo as a humanist beacon, an exemplary figure of learning and discovery.

The drawings in Oxford show the range of Leonardo's interests, but are not reassuringly rational. There are compelling Escher-like geometric puzzles composed of interlocking cubes, allegorical drawings of an old woman riding a skeleton, and figures with second bodies sprouting out of their stomachs. There's the face of a fantastically ugly man drawn with huge force, the pencil brutally delineating the grotesque mouth, then creating the elephantine skin in shading so subtle you feel the flabby texture of his hanging throat. According to Vasari, his 16th-century biographer, Leonardo used to look out for people with facial abnormalities in the streets of Florence, then follow them to get a better look.

This is the Leonardo of the surrealists we're looking at. In his book Beyond Painting, the German artist Max Ernst tells how, when he was young, he read in Leonardo's treatise on painting that you can imagine a landscape by looking at a blot on a wall. From this, Ernst says, he developed the habit of staring at marks on walls and floorboards and seeing strange formations - and this is where his surrealist art comes from.

Beyond Painting, the title of Ernst's book, might be a chapter in a life of Leonardo. The thing that baffled people about Leonardo a hundred years ago was why he did so little painting. Today we've rationalised this problem away. We see Leonardo as an early scientist as much as an artist. It doesn't bother us that he spent so much of his time dissecting bodies, designing flying machines and attempting to divert the river Arno for military purposes. But we miss the strangeness of Leonardo if we ignore the fact that most of his research was absolutely useless. When Leonardo dissected corpses and drew them, he wasn't trying to improve his knowledge of anatomy for artistic or medical purposes; he just wanted to produce the notebooks. Leonardo was a genius but he never constructed any theories to explain his discoveries.

Leonardo's notebooks are like modern collages. His famous mirror writing is a visual artefact in itself. Pages are covered in heterogeneous images - a dissected organ next to a horseman, an allegory next to a crossbow. And perhaps what he is doing is announcing a new concept of art. In his unfinished cartoon for the Adoration of the Magi in the Uffizi in Florence, Leonardo has drawn a crumbling palace whose picturesque ruins are haunted by ghostly horse riders who seem to enact battles in space and who cannot quite be enumerated or fully seen. It's hard to imagine how this painting could have been finished and kept its strange fascination; and the inclusion of a classical ruin might be seen as a key to the work, to Leonardo. Ruins are sublime, the picture might say. Art is not about making things to last for ever - justification in advance for the way Leonardo's wall paintings rotted because he didn't use proper fresco techniques.

The drawings in Oxford are the perfect microcosm of this idea of art as something that doesn't complete itself and so remains infinitely suggestive. There's a picture puzzle of interlocking cubes that might go on forever. Looking into this architecture - which could never make sense in reality - is like looking into an infinite space in a dream. In fact it's like looking into the original dreamscape of which Salvador Dali's paints are a pastiche.

Dali identified with Leonardo even more obsessively than Ernst. Dali really did suffer from the "narcissism" and impotence Freud ascribes to Leonardo. He read Freud's book when he was young and identified absolutely with Leonardo. He painted Leonardo-like rocky landscapes and grotesque figures that come straight out of Leonardo's drawing; in his 1937 painting The Metamorphosis of Narcissus, whose title refers to Freud's diagnosis of Leonardo, the flowing mane of hair hovering over the yellow hand could have come out of one of Leonardo's androgynous portraits.

Leonardo has haunted modernism in quite uncanny ways. In 1911 the Mona Lisa was stolen from the Louvre and Picasso was suspected of being involved. One of Picasso's friends, the poet Guillaume Apollinaire, was arrested in connection with the theft. According to Pablo Picasso, the scandal cost Apollinaire his life. Desperate to repair his reputation, he enlisted in the French army during the first world war and was mortally wounded.

The most famous image of Leonardo in modern art, however, is Marcel Duchamp's drawing of a moustache and a beard on a tourist reproduction of the Mona Lisa. The initials beneath, LHOOQ, are a dirty joke, a pun on the French for: "She's got a hot arse." This is an obscene attack on the very idea of an artwork as an object to be revered. It might seem to be an attack on Leonardo himself. But it can also be seen as a reply to Freud.

Duchamp spent his entire career deliberately repeating Leonardo's "failure." He started as a painter but stopped painting and instead chose objects to nominate as "art". Then he gave up art and claimed he was a researcher. Duchamp's science has the same relationship to modern technology as Leonardo's drawings to the early scientific revolution: none at all. And, like Leonardo's, Duchamp's artworks are ruins. When he became famous in the 60s, his early Readymades had to be reconstructed because they had vanished. His art was a self-consciously futile game, like Leonardo's picture puzzles.

There really is evidence of a sense of futility and pessimism in Leonardo. In his notebooks he obsessively repeats the phrase: "Was anything done? Was anything done?" Leonardo seems to have seen no distinction between art and life. He put just as much work into devising toys for the court, such as a robot lion, as he did into his paintings. There is evidence that he found painting a chore. He loved the drawing, the development of ideas, but when it came to finishing the work, he farmed it out to assistants or just stopped. Was he the first conceptual artist?

Leonardo cut open bodies and drew their innards. He cut open a pregnant woman and opened her womb to draw the baby crouched inside. Damien Hirst's Turner prize-winning artwork Mother and Child, Divided, which allows us to look inside a bisected cow and calf, is an anatomy lesson instantly recognisable as Leonardesque. Vasari relates how Leonardo made a balloon out of a cow's bladder and inflated it until it was a translucent sphere filling an entire room.

Leonardo's drawings are inexplicable. They are the work of a mind that deliberately rejects the finished and easy for an endless dabbling in marginalia. In Leonardo's paintings the background of mysterious rocks is sometimes the only thing he can be proved to have painted. Perhaps we have made Leonardo into a bearded saint because we don't want to admit how much we have in common with this time-waster staring at walls and looking for the pattern in the cracks.