Andreas Gursky's Rhein II fetched £2.7m last year, setting a record for any photograph sold at auction. Photograph: Andreas Gursky/AP Photo/Christie's

For 180-years, people have been asking the question: is photography art? At an early meeting of the Photographic Society of London, established in 1853, one of the members complained that the new technique was "too literal to compete with works of art" because it was unable to "elevate the imagination". This conception of photography as a mechanical recording medium never fully died away. Even by the 1960s and 70s, art photography – the idea that photographs could capture more than just surface appearances – was, in the words of the photographer Jeff Wall, a "photo ghetto" of niche galleries, aficionados and publications.

But over the past few decades the question has been heard with ever decreasing frequency. When Andreas Gursky's photograph of a grey river Rhine under an equally colourless sky sold for a world record price of £2.7 million last year, the debate was effectively over. As if to give its own patrician signal of approval, the National Gallery is now holding its first major exhibition of photography, Seduced by Art: Photography Past and Present.

The show is not a survey but rather examines how photography's earliest practitioners looked to paintings when they were first exploring their technology's potential, and how their modern descendants are looking both to those photographic old masters and in turn to the old master paintings.

What paintings offered was a catalogue of transferable subjects, from portraits to nudes, still lifes to landscapes, that photographers could mimic and adapt. Because of the lengthy exposures necessary for early cameras, moving subjects were impossible to capture. The earliest known photograph of a person was taken inadvertently by Louis Daguerre – with Henry Fox Talbot one of photography's two great pioneers – when he set up his camera high above the Boulevard de Temple in Paris in 1838. His 10-minute exposure time meant that passing traffic and pedestrians moved too fast to register on the plate, but a boulevardier stood still long enough for both him and the bootblack who buffed his shoes to be captured for ever.

When Daguerre turned his camera on people rather than places the results were revelatory. Elizabeth Barrett Browning was so struck by Daguerreotypes that she rhapsodised over "the very shadow of the person lying there fixed forever". The fidelity of features captured meant that she "would rather have such a memorial of one I dearly loved, than the noblest Artist's work ever produced" not "in respect (or disrespect) of Art, but for Love's sake". If, however, her photographer followed the advice of Eugène Disdéri, who wrote in 1863 that: "It is in the works of the great masters that we must study the simple, yet grand, method of composing a portrait," she could satisfy love with both physiognomy and art.

My Grandchild by Julia Margaret Cameron. Photograph: Hulton/Getty

What some pioneering photographers recognised straight away was that photographs, like paintings, are artificially constructed portrayals: they too had to be carefully composed, lit and produced. Julia Margaret Cameron made this explicit in her re-envisagings of renaissance pictures. Her Light and Love of 1865, for example, shows a woman in a Marian headcovering bending over her infant who is sleeping on a bed of straw. It is part of a line of nativity scenes that is as long as Christian art, and was hailed by one critic as the photographic equivalent of "the method of drawing employed by the great Italian masters". I Wait, 1872, shows a child with angel's wings resting its chin on folded arms and wearing the bored expression that brings to mind the underwhelmed cherubs in Raphael's Sistine Madonna. Such photographs were not direct quotations from paintings, but they raised in the viewer's mind a string of associations that gave photography a historical hinterland.

If Cameron and contemporaries such as Oscar Rejlander and Roger Fenton (who took numerous photographs of still-life compositions of fruit and flowers as well as his better known pictures of the Crimean war) were keen that their photographs should reflect their own knowledge of art, the links went both ways. In 1873, Leonida Caldesi published a book of her photographs of 320 paintings in the National Gallery, and her intended audience was not just the public but artists themselves, for whom the photographs were both more accurate and more affordable than engraved reproductions. By 1856, thanks to Fenton's photographs, artists could study classical statues in their own studios.

It was perhaps in depicting the nude – such as Fenton's bestselling photograph of the discus thrower Discobolus – that photography could repay its debt to art. Hiring a life model was expensive, and engravings were a poor substitute. Delacroix was one artist who "experienced a feeling of revulsion, almost disgust, for their incorrectness, their mannerisms, and their lack of naturalness". He praised instead the painterly aid provided by académies (books of nude photographs) since they showed him reality: "these photographs of the nude men – this human body, this admirable poem, from which I am learning to read". He even helped the photographer Eugène Durieu pose and light his models. And in 19th-century Britain and France, when pornography was illegal, photographs of the nude were in demand from customers who had no artistic interests.

When it came to landscape photography the new medium appeared just as the impressionists were beginning to work in the open air. Some commentators saw photography's real challenge to painting as lying in its ability to capture what the photographer and journalist William Stillman called in 1872 "the affidavits of nature to the facts on which art is based" – the random "natural combinations of scenery, exquisite gradation, and effects of sun and shade". Another practitioner, Lyndon Smith, went further, declaring landscape photography the answer to the "effete and exploded 'High Art', and 'Classic' systems of Sir Joshua Reynolds" and "the cold, heartless, infidel works of pagan Greece and Rome".

Being new was a laborious business, however. Eadweard Muybridge, the British-born photographer who first captured animals in motion and as a result ended the old painterly convention of showing horses running with all four legs off the ground, was primarily a landscape photographer. His pictures of the Yosemite wilderness, for example, involved carrying weighty cameras, boxes of glass negatives, as well as tents and chemicals for a makeshift darkroom, up mountains and through forests. Monet's painting expeditions by contrast required only paint and canvas.

If early photographers had no option but to negotiate their own engagement with painting their modern descendants can call on nearly two centuries of photographic history. It is a point the exhibition makes by combining old and new. So when a contemporary photographer such as Richard Billingham photographs an empty expanse of sea and sky in Rothko washes of slate blues and greys (Storm at Sea) he is referring to a heritage that encompasses both the monochrome tonality of Gustave Le Gray's atmospheric photographic seascapes of the 1850s and a painting such as Steamer on Lake Geneva, Evening Effect, 1863, by the Swiss artist François Bocion.

An image of a couple in their suburban home, from Martin Parr's album
Signs of the Times, England, 1991 Photograph: Martin Parr/Magnum

The point is made across the different media. A brittle portrait of a suburban couple from Martin Parr's 1991 album Signs of the Times, for example, is contrasted with Gainsborough's Mr and Mrs Andrews of 1750. Both are images of possession and entitlement, the latter displaying landowners at ease amid their fields and woods, comfortable with both themselves and their station, the former a couple posing stiffly in their sitting room.

The curators of the National Gallery exhibition have avoided using many of contemporary photography's biggest names (there is no Andreas Gursky and no Cindy Sherman for example), and nor do they include photorealist painters such as Gerhard Richter or Andy Warhol. Their choices are largely less celebrated figures as if to show how deep is the seam of photographers still working with the long visual past. When in 1844-6 Fox Talbot published his thoughts about photography he gave the book (the first publication to contain photographic illustrations) the title The Pencil of Nature. This exhibition lays out what photography's founding father could never know: how the camera has also always been the pencil of art.