The early Victorians were the first generation to see themselves through the camera lens, but the idea of photography, the possibility of making an exact reproduction of visual experience, was one – like flight and the philosophers' stone – that had haunted the imagination of inventors for centuries. The "camera obscura" or "dark room" that could project images on to a blank surface was known in antiquity, but a long hiatus followed. Then, at the end of the 18th century it was found that paper coated in silver nitrate would retain the image of an object placed on it for a tantalising moment before it faded. As the Georgian age came to an end, the enthusiasm for light shows and spectacles of all sorts reached fever pitch – as if photography were being willed into existence by sheer popular demand. London and Paris were full of novel experiences with enticing names – panoramas, cycloramas and, in Leicester Square, Philip de Loutherbourg's Eidophusikon, in which pulleys, mirrors and sound effects conjured up a plausible storm at sea.

The building that housed one of the most successful of the light shows, the Diorama, still exists in Regent's Park. In a kind of early Imax, the audience sat in a rotating drum to watch clouds, apparently, pass over the moonlit ruins of Holyrood. Its inventor was the artist Louis Daguerre, who was first across the line with a true photographic process in 1839, in France. The sensation caused by his breakthrough prompted William Henry Fox Talbot, who had been working quietly in Wiltshire at his home, Lacock Abbey, to unveil his own version, which he called the calotype. In his early prints, the Gothic tracery of Lacock shimmers, ghostly, into being, fragile and mysterious beside the pin-sharp immediacy of the daguerreotype. From the beginning, photography could be many things.

One thing it always was, was popular. It never entirely left the show business world from which it had emerged. By October 1839 the Adelaide Galleries in Pall Mall were already offering daily demonstrations of the daguerreotype process. These had to compete for attention with the galleries' famous – and ear-splitting – steam gun, which went off every hour, as well as a 40in electric eel from South America out of which Michael Faraday was able to get a "most intense" spark. By the mid-century, technical improvements had made photography cheap enough for a mass market. The 1861 census recorded 2,879 professional photographers in England and there were many more keen amateurs.

While the movement of Victorian society as a whole tended to make class divisions ever more rigid, photography managed to be classless. Cumbersome puns in Punch about dustmen having their "cart de visite" photographed reflected the speed with which the "lower orders" seized on a chance to sit for the sort of portrait the middle and upper classes had been commissioning for centuries. Photography was also, from the beginning, considered a suitably genteel pastime for women, who produced some of the most enduring portrait studies of the 19th century. The camera at times perhaps allowed them to express ideas that a lady might hesitate to put into words. Julia Margaret Cameron's study of Tennyson made the laureate look, he thought, like a "dirty monk", and he was pleased with it. Lady Alice Mary Kerr's darkly glamorous vision of the poet and serial seducer Wilfrid Scawen Blunt transports his erotic appeal in full force across a century and a half.

Questions were asked, of course, the same questions that are usually asked about new technologies – notably "is it art" and "is it a threat to society as we know it" – and as usual many of the answers were wrong. The history painter Paul Delaroche's immediate response, "from today painting is dead", turned out to be premature, while the Times's confidence that photography would never replace the "completeness" of the painted panorama was also misplaced. But the popularity of photography did not, at first, alienate those who saw themselves as guardians of high culture. Ruskin, as an architectural artist, reassured his elderly father that "photography is a noble invention, say what they will of it. Anyone who has worked, blundered and stammered as I have done [for] four days, and then sees the thing he has been trying to do so long in vain, done perfectly and faultlessly in half a minute, won't abuse it afterwards."

Charlotte Brontë, who seems to have been the first novelist to use "daguerreotype" as a verb, was also an enthusiast. In Shirley, published in 1849, Caroline Helstone, encountering her would-be lover unexpectedly, finds his image is "struck on her vision with painful brightness . . . as vividly as if daguerreotyped". The implication is that somehow the photographic image would be even more real, more intense, than his physical presence. It was this truthfulness, the potential of "nature's own transcript of herself", to offer a moral purity beyond human fallibility that appealed to the more thoughtful early Victorians.

Of its social effects, the art critic Elizabeth Eastlake spoke for many in heralding it as an invention "made for the present age". The age was one of railways and expanding empire, and it wanted, she believed, a supply of "cheap, prompt and correct facts" to aid its steam-driven progress. This was what, to some extent, it got. Journalism was transformed as engravings of photographic images and then photographs themselves were used in magazines and newspapers. The Crimea soon provided an occasion for the first war photographs. Photographic images show Nelson's Column going up in the 1840s and the Vendome Column coming down under the Paris commune. But news pictures were not the most popular, and it was decades before anyone thought seriously of using a camera to document social conditions. Landscapes, historic sites, celebrities, especially Dickens, and endless pictures of themselves were what the Victorians liked best.

It was not long before the supposed objectivity of the camera came into question. As a sceptical Mark Twain pointed out: "You can't depend on your eyes if your imagination is out of focus." Besides Eastlake's vision of ever expanding truth and Charlotte Brontë's endorsement of the emotional force of the image, there was always another, more shadowy, reality. Fakes, mistakes, tricks and lies were endemic in photography from the beginning, and grew in number and variety as photographic techniques improved. EP Loftus Brock was an early, if inadvertent, demonstrator of its limits as a scientific method when he used it at Stonehenge to further his investigations of the alignment of the stones. Having engaged a photographer to observe with him the sunrise at midsummer in order to test the popular belief that the sun rose directly over the Heel Stone, he reported back to the British Archaeological Association that this fact was now "verified beyond all question". Since the sun actually rises slightly to the north, either Brock's camera or his imagination must have been out of focus.

Nor was moral purity guaranteed. It was not a coincidence that the Obscene Publications Act of 1857 followed shortly in the wake of new developments in photography. The wet collodion process, which introduced glass instead of paper negatives, was published without patent protection in 1851. Shorter exposure times and cheaper prints were achieved soon afterwards and a booming market for pornographic pictures was one immediate unintended consequence. In response, the Society for the Suppression of Vice campaigned effectively for the new law. It was less effective, however, in defining obscenity. It was over dirty pictures, rather than more elevated questions about craftsmanship and intention, that the debate about whether or not photography was art became interestingly heated.

It first came to a head at the Manchester Art Treasures Exhibition, where OG Rejlander showed his enormous photographic composition The Two Ways of Life. Printed from 30 separate negatives, it featured groups of allegorical figures, among whom the vices were portrayed by naked women. Despite Rejlander's robust defence of his work as art – the groups, he argued, were entirely based on classical sources – the picture caused a scandal. When the Scottish Photographic Society later put it on display, it was forced to take it down on "moral grounds" – though the objectors had the wind taken out of their sails by Queen Victoria, who clearly thought The Two Ways was art and bought a print for Prince Albert. He hung it in his private suite at Windsor.

Victorian erotica today looks for the most part as monumental and unexciting as Victorian furniture. The 19thcentury pictures that give us most pause, like Lewis Carroll's studies of young girls, were in their day quite unexceptionable. Perhaps still more disturbing are the documentary images of "natives", "lunatics" and criminals by which it was hoped that science, first as physiognomy and later as eugenics would open the way to a systematic understanding of human nature. The shudder of hindsight shouldn't blind us to the sincerity or the nobility of the 19th century's belief in the power of its new medium to scan the soul. Darwin's The Expression of the Emotions in Man and Animals used images of mental patients taken by the neurologist Guillaume Duchenne de Boulogne at the Salpêtrière hospital. Yet even at the time there were those who noticed that studies of "hysteria" and "megalomania" mainly serve to underline how little of the mind the face reveals.

As the century wore on, a certain disillusionment set in. Trollope thought the photograph much less useful to the novelist than Charlotte Brontë had. "Let daguerreotypers do what they will," he wrote in Barchester Towers, "they will never achieve a portrait of the human face divine." Ever the pessimist, Thomas Hardy, who thought that Darwin's discoveries had destroyed all hope of happiness for the over-evolved species that was mankind, saw in photography the potential for positive malevolence. In his A Laodicean, of 1880, Paula Powers loses faith in her lover, Somerset, when shown a picture of him apparently exhibiting "the wild attitude of a man advanced in intoxication". This kind of manipulation of the image, achieved in Hardy's story by Somerset's enemy William Dare, was already, Hardy noted, a popular jape with "certain facetious persons of society". Joke pictures of the German emperor in a screaming rage or of the pope dead drunk did a brisk trade.

A more calculated manipulation of images towards the end of Victoria's reign was responsible for the rash of cloudy spirit photographs, veils of ectoplasm and hovering hands that convinced Conan Doyle and many others that the camera could record the dead as truthfully as the living. As embarrassing in their way as the erotica, the faked images of seances make a telling counterpart to the hundreds of images taken over the same period to celebrate the queen's diamond jubilee in 1897. The jubilee saw photography reach its apogee as an instrument of imperial triumphalism. It would record, people believed, for "after years" Great Britain's work of "civilising, of governing, of protecting life and property, and of extending the benefits of trade and commerce" across the world.

What the images reveal now, as they settle back into the lengthening history of photography, is the extent to which every Victorian certainty was shadowed by an equally profound doubt. For each confidently posed picture of a tiger hunter or the royal family there is a joke in dubious taste, a stocky nude or a fragile hope of life after death. As photography found its place in culture and society, no longer a technical novelty or a lever to prise open the moral truths of humanity, it gave back to the Victorians what they brought to it. Now it passes them on to us in ways that would have surprised them. "A photograph is a most important document," said Mark Twain, "and there is nothing more damning to go down to posterity." The Victorians are not damned by their photographs, but they are revealed, in ways that would surprise them, telling truths they hardly knew themselves.

Points of View: Capturing the 19th Century in Photographs is at the British Library until 7 March 2010