It is usual, in discussions of erotica and obscenity, to talk about art and pornography as if they were opposites. In fact, argues Tom Lubbock, the whole purpose of much great art is to cause sexual arousal

In the early 1970s, Kenneth Tynan was doing some research. He was in the first stages of conceiving his erotic revue, Oh! Calcutta, and he found himself at a live show in Hamburg, one hand on his stopwatch.

"At the Salambo Erotic Theatre I see fucking on the stage for the first time and am enchanted. A group of well-built, clean and mutually affectionate young people constitute the show, which is imaginatively lit with evocatively orgasmic sound effects. Cocks are sweetly and diligently sucked, and the leading pair (the girl is a Scot) fuck for 18 minutes in a variety of postures. The full rectal presentation, with the dear Scot's bum outstretched to bursting, as the pink piston of prick slides up and down, is something I shall never forget."

And is it art? Well actually, it's not so far off. But somehow we manage not to notice.

If Tynan had stayed in London, and gone to a venue on the fringes of Soho, he might have found there several equally enchanting spectacles. He might have feasted his eyes on any number of well-built and clean young people. And he might have enjoyed, for example, a group scene, with at its centre a young man and a woman, both naked, sweetly making love, mouth to mouth, fingers to nipples; or another, in which a naked child whips a naked man with a topless woman looking on; or a naked woman displayed, bound in chains to a rock; or a naked woman having full sex with a large bird; or an orgy involving adults, children and animals both living and dead though nothing in Hamburg or in Oh! Calcutta went quite so far as that.

The venue I have in mind is, of course, the National Gallery in Trafalgar Square. And the spectacles I've described are paintings by (respectively) Bronzino, Veronese, Ingres, Michelangelo (attrib.) and Poussin. And every day, with no admission fee and no age restrictions, the public are admitted between the hours of 10am and 6pm, and children children are allowed, indeed encouraged, to look at these things. And somehow we don't notice. We're experts at not noticing. Even with our post-Freud minds, or perhaps especially with our post-Freud minds, we're inoculated against seeing what's in front of our noses. We're quite good at spotting sex when it isn't expressly there. We might well observe how strangely erotic a Crucifixion is, for instance. But as for noticing how unstrangely erotic, how overtly lascivious, the busy tongues and fingers in Bronzino's Allegory with Venus and Cupid are, that seems to be beyond us. (As the National Gallery's catalogue puts it, "agreement on the meaning of this picture has not yet been reached".) Wittgenstein noted how Freud himself would offer sexual interpretations of all kinds of dreams, but oddly never got around to mentioning explicitly sexual dreams; yet these, as Wittgenstein said, are "as common as rain".

Likewise, explicit sex among the old masters as common as rain. But it may take a stranger to see it, and to point out that not only the Emperor but practically everyone else has no clothes, and are at it like dogs. The poet Baudelaire recalled how he had taken a friend to a museum: "Louise Villedieu, a five franc whore, who, when accompanying me one day to the Louvre where she had never been started blushing and covering her face; and plucking all the time at my sleeve, she asked, before the immortal statues and paintings, how people could put such obscenities on public display."

And when it is pointed out? Well, you have to admit it. OK, yes, in a way, if you insist, there is a great deal of open sex going on in the art of the old masters. Well, obviously.

Obviously. And last year, the Barbican Gallery dedicated a whole exhibition to this obvious point. The notice outside Seduced: Art and Sex from Antiquity to Now warned that "This exhibition contains work of a sexually explicit nature."

In fact, it contained very little else. It presented such a parade of pictorial prick and bum, such a variety of postures, from Greek pots and Roman murals, from Leonardo, Rembrandt, Fragonard, Fuseli, Turner, Rodin, Picasso, Duchamp, Bacon, Warhol, Jeff Koons, that it seemed we'd never be able not to notice it again. The show began with a fig leaf: a cast of the bronze fig leaf that was originally made, for the benefit of Queen Victoria, to conceal the genitals of the replica of Michelangelo's "David" that stands in the Victoria and Albert Museum. But the target of the show was really the fig leaves that we still wear over our eyes, whenever we enter the precincts of art and its chosen mode of attack was saturation bombing.

Most people, I suppose, coming across the heading "Art and Sex", would think of the nude first of all. And nudes, female and male, are certainly part of this story. Lying and posing in varied postures of passive availability or active flaunting, they're clearly up for it and more. The Venetian nudes of Giorgione and Titian are openly playing with themselves. And it may even seem that the nude is the main way that European painting does sex. It all gets displaced on to the solitary, voluptuous body or, rather, on to the relationship between this body and the eyeing viewer. Japanese woodcuts may depict graphic scenes of intercourse between men and women, with enormously enlarged genitalia, so that no detail of the pink piston's action escapes us. But Western art doesn't show these things directly.

It does, though. Seduced included some of those Japanese prints, such as Hokusai's extraordinary undersea vision of an octopus performing cunnilingus on a girl-diver. And it had an amusing Turkish image of a ring of trouserless gentlemen wearing fezzes, doing a circular conga, each one entering the one in front from behind. But the exhibition also emphasised that sex in European art is not confined to solo nudity. Scenes of interpersonal lust penetration, masturbation, fellatio are part of the canon too.

The centrepiece of European sex art is a legendary series of images called I Modi "The Postures". A Renaissance Kama Sutra, it was designed by Raphael's pupil Giulio Romano, engraved by Marcantonio Raimondi, and first published in 1524. In his Lives of the Artists Vasari recorded the fact with disgust: "In 20 sheets, the same number of positions, attitudes and postures in which immoral men lie with women, and which was worse for each position Messer Pietro Aretino created a most obscene sonnet."

Aretino's accompanying poems, full of cul and cazzo and potta, are pretty raw stuff. As for the images, legendary is what they mainly remain. The Pope had Raimondi imprisoned for obscenity, and the church police managed to hunt down and destroy his prints so successfully that no complete edition is now known. Just one of the original engravings survives, though others are preserved in crude copies made by a 19th-century German dilettante.

In the Barbican show, I Modi were represented only by a series of key-hole glimpses a set of tantalising, postage-stamp-sized fragments that someone cut out from the original prints and stuck into an album. Whoever made this edit, they were for some reason mainly interested in the figures' facial expressions. The odd foot or breast appears. Almost everything else is off-picture, to be imagined. But faced with such images, and with many others just as flagrant, the old question returns. It may be sex. Can it possibly be art?

Around the time that Kenneth Tynan was visiting Hamburg, the art historian Kenneth Clark was appearing as an expert witness before Lord Longford's Committee on Pornography, and he gave his opinion on this question. "To my mind art exists in the realm of contemplation... The moment art becomes an incentive to action, it loses its true character. This is my objection to painting with a Communist programme, and it would also apply to pornography."

His objection would presumably also apply to painting with a Christian programme ie, a large proportion of European art but let that pass. What Clark articulates is an idea that we've all picked up somewhere or other. Art stands apart. Art makes nothing happen. It should never be, as Clark nicely puts it, "an incentive to action" though in this case it isn't quite action that we're talking about, but something rather more involuntary.

The issue, the problem, the thing that art as art mustn't incite or show, is sexual arousal. Actually, even Clark didn't wholly rule it out. In his classic study of The Nude, he insisted that "no nude, however abstract, should fail to arouse in the spectator some vestige of erotic feeling, even though it be only the faintest shadow". Others have put it more strongly. "Je peint avec mon bitre," Renoir boasted: I paint with my prick. And Seduced contained a forest of erections by Aubrey Beardsley, Egon Schiele, the contemporary painter Marlene Dumas, and a rare Roman marble that hadn't had it knocked off. As for the viewer, in one his last poems WB Yeats intoned:

Michael Angelo left a proof

On the Sistine Chapel roof,

Where but half-awakened Adam

Can disturb globe-trotting Madam

Till her bowels are in heat...

Yeats imagines a complacent tourist in the Vatican, some proper American matron perhaps, confronted by that magnificent body and finding herself dissolving in uncontrollable lust (the proximity of the word globe-trotting to the word bowels gives these lines a particular pungency). Nor does Yeats feel there's anything wrong in this response. One reason we have art, he says, is to help us "fill the cradles right".

This view has good historical support. The Renaissance art critic, Giovanni Paolo Lomazzo, celebrated the art of painting for its ability to stimulate the viewer in all sorts of ways. A picture "will cause the beholder to wonder when it wonders; to desire a beautiful young woman for a wife when he sees her painted naked; to have fellow-feeling when he sees affliction; to have an appetite when he sees the eating of dainties... etc." Sexual arousal is calmly listed as just one of the uses of painting.

Again, a perfectly respectable 17th century critic, Giulio Mancini, giving practical guidance on the best way to hang pictures in the home, advises: "Lascivious pieces are to be placed in private rooms, and the father of the family is to keep them covered, and only uncover them when he goes there with his wife, or an intimate who is not too fastidious. And similar lascivious pictures are appropriate to the rooms where one has to do with one's spouse; because once seen they serve to arouse one, and to make beautiful, healthy and charming children..." To fill the cradles right, in short.

This gentleman's backroom stuff may make you think of Goya's famous pair of matching pictures, the "Maya Clothed" and the "Maya Naked", originally designed to be hung one in front of the other, and hinged, so that in an appropriate gathering the dressed up image could be swung back to reveal the naked one; pictorial striptease.

Or there is Courbet's astonishing painting The Origin of the World: simply a close-up view, between open thighs, of a woman's pudenda. It was originally painted for a Turkish-Egyptian diplomat, who kept it behind a cover in his dressing room. And it was long believed lost - before it turned up, on his death, in the collection of the psychoanalyst Jacques Lacan, who had also hung it behind a sliding panel.

The image can even go beyond arousal, almost to consummation. When the surrealist Georges Bataille remarked that "no collector could ever love a work of art as much as a fetishist loves a shoe", he hadn't really thought the matter through. For while an image of a house will never be a substitute for a house, nor an image of an apple for an apple, an image of a man or a woman can in some cases be a working substitute for the real thing almost as good, or depending on your inclinations, even better.

There are many tales of iconophilia. The ancient historian Pliny gives one of the first, the story of a statue of Venus in the town of Cnidos, the masterwork of the sculptor Praxiteles. A young man became infatuated with this figure with a half-smile on its face, broke one night into its sanctuary, and "embraced it tightly in his arms, warming the cold marble with his burning kisses" and ejaculated "contaminating it with his lust, so that the stains ever after remained, as a monument to his impiety."

And Leonardo himself recalled: "It once happened to me that I made a picture representing a sacred subject which was bought by one who loved it and then wished me to remove the symbols of divinity that he might kiss it without misgivings."

Yet having got to this point in the story, with maybe a few misgivings, having agreed that there's a great deal of sex in art, and that there are no hard distinctions between art and erotica and pornography, and even that sexual arousal is a normal and not necessarily despicable response to images while perhaps stopping short of active iconophilia, beyond the occasional peck still, having got to this point, what then? Or so what?

There are two lessons to draw: first, a negative one, about censorship. Art's sheer saturation with sex and sexual depravity is likely to make a monkey of current legislative attempts to criminalise the representation of such scenes in, for example, photography (both in the UK and beyond). Sharp lines just can't be drawn here.

But if that was all, it wouldn't be much. We would be treating art simply as a mechanism for making things culturally respectable as a kind of fig leaf itself. We wouldn't be asking what positive contribution it had to make. And surely, in the matter of art and sex, art ought to have something important to add.

That was the great failure of the Barbican's Seduced show. Sex, sex as such, was its punchline, its QED. The curators described it as "a celebration of the makers of images who present such varied delights and surprises, of the artistry devoted to one of the great givens of the human condition."

But sex, beyond a pretty basic level, is not a given. It's a matter of experience and a matter of taste. As the poet Ezra Pound observed: "Sex, in so far as it is not a purely physiological reproductive mechanism, lies in the domain of aesthetics..."

Which is where art really comes in. The makers of I Modi, after all, weren't just celebrating a given. They were passing on some useful tips, some how tos and why not trys. And in more subtle and insinuating ways, many artists including many great artists have explored and extended the repertoire of desire.

It's normal to think that artists the Pre-Raphaelites, say can coin new kinds of beauty. But they also create new varieties of sexiness. On our behalf, they imagine physical shapes and sensations we didn't know we wanted. The body-types invented by Donatello and Michelangelo, Titian and Rubens, Ingres and Courbet and even Francis Bacon, aren't just sex-objects, they're sex-object-lessons. But you don't need a dedicated exhibition to make this point. Any major collection will do.

So take that thought with you, next time you go round the National Gallery. The old masters, they teach us how to love.

A version of this article appeared in 'The Independent' last year