Image copyright ALAMY Image caption A reconstruction of the palaces built by the Assyrian King Ashurbanipal by Austen Henry Layard

Two of the ancient cities now being destroyed by Islamic State lay buried for 2,500 years, it was only 170 years ago that they began to be dug up and stripped of their treasures. The excavations arguably paved the way for IS to smash what remained - but also ensured that some of the riches of a lost civilisation were saved.

In 1872, in a backroom of the British Museum, a man called George Smith spent the darkening days of November bent over a broken clay tablet. It was one of thousands of fragments from recent excavations in northern Iraq, and was covered in the intricate cuneiform script that had been used across ancient Mesopotamia and deciphered in Smith's own lifetime.

Some of the tablets set out the day-to-day business of accountants and administrators - a chariot wheel broken, a shipment of wine delayed, the prices of cedar or bitumen. Others recorded the triumphs of the Assyrian king's armies, or the omens that had been divined by his priests in the entrails of sacrificial sheep.

Smith's tablet, though, told a story. A story about a world drowned by a flood, about a man who builds a boat, about a dove released in search of dry land.

Smith realised that he was looking at a version of Noah's Ark. But the book was not Genesis. It was Gilgamesh, an epic poem that had first been inscribed into damp clay in about 1800BC, roughly 1,000 years before the composition of the Hebrew Bible (the Christian Old Testament). Even Smith's tablet, which had been dated to some point in the 7th Century BC, was far older than the earliest manuscript of Genesis.

A month or so later, on 3 December, Smith read out his translation of the tablet to the Society for Biblical Archaeology in London. The Prime Minister, William Gladstone, was among those who came to listen. It was the first time an audience had heard the Epic of Gilgamesh for more than 2,000 years.

Image copyright ALAMY

Smith's reading caused a sensation. There were some who seized on the poem with pious satisfaction, taking it to corroborate the essential truth of the Bible. But there were others who found it more troubling. As the New York Times put it in a front page article the following day, the Flood Tablet had exposed "various traditions of the deluge apart from the Biblical one, which is perhaps legendary like the rest".

Coming less than 15 years after Darwin's On the Origin of Species, the Epic of Gilgamesh felt to many like another great crack in the edifice of Victorian Christianity.

The story of how the Flood Tablet emerged from the mud of northern Iraq begins in a place called Kouyunjik - one of the archaeological sites now being mined for Assyrian antiquities by IS. It's a story told by Prof David Damrosch of Columbia University in The Buried Book: the Loss and Rediscovery of the Great Epic of Gilgamesh.

Kouyunjik sits directly opposite the Iraqi city of Mosul on the banks of the Tigris, and 2,700 years ago it was part of Nineveh, the last capital of the Assyrians. At its height, this was an empire that stretched from the shores of the Persian Gulf to the mountains of Anatolia and the flood plains of Egypt. For a period of about 300 years (roughly 900 - 600BC), it was the most advanced civilisation ever seen, a technological superpower built on the wealth of its merchants and the ruthlessness of its armies. A carving found at Kouyunjik shows the Assyrian King Ashurbanipal enjoying a picnic in his garden while the severed head of his enemy, the Elamite king Teumman, swings from the branches of the trees.

But Assyria was not invulnerable. In 612BC, Nineveh was sacked in a rebellion led by the Babylonians. They left the world's richest city in ruins, its palaces smouldering, its people dead or deported into slavery. Dust settled over the shattered library of the dead King Ashurbanipal, and over his carefully transcribed copy of the Epic of Gilgamesh.

Two-and-a-half millennia later, in the winter of 1853, the poem was lifted out of the dirt by a man called Hormuzd Rassam.

Rassam had grown up in Mosul, just across the river. At a time when the imperial powers saw the locals as little more than spade handlers and donkey boys, he had been appointed by the British Museum to lead the most important archaeological excavation of the age. He was, by some distance, the first archaeologist born and raised in the Middle East.

Rassam's family were Chaldean Christians, descendants of the ancient Assyrians who had converted to Christianity in the Fourth Century and had remained ethnically distinct from the Arab and Kurdish populations of Iraq. This is the same community that has, in the past year, been forced by Islamic State to convert to Islam, pay a special tax, or be killed. Most of Mosul's Assyrian Christians now have fled east into the autonomous region of Kurdistan or north, across the border, into Turkey.

Image copyright Reuters

When Rassam was growing up, Mosul was a peaceful place. The city was part of the slowly dying Ottoman Empire, a provincial backwater that offered few prospects for a young man of energy and talent. But in 1845, when Rassam was 19 years old, he met someone who changed the trajectory of his life - Austen Henry Layard.

Layard was an adventurer who had arrived in the Middle East on horseback at the end of the 1830s, armed with plenty of cash and a pair of revolvers. By the time he got to Mosul he had already seen the temples of Petra and Baalbek, as well as the living cities of Damascus and Aleppo. But it was the unexcavated ruins of Iraq that really captured Layard's imagination.

"A deep mystery hangs over Assyria, Babylonia, and Chaldea. With these names are linked great nations and great cities... the plains to which the Jew and the Gentile alike look as the cradle of their race," he wrote.

"As the sun went down, I saw for the first time the great conical mound of Nimrud rising against the clear evening sky. It was on the opposite side of the river and not very distant, and the impression that it made upon me was one never to be forgotten... my thought ran constantly upon the possibility of thoroughly exploring with the spade those great ruins."

After years of negotiation with the Ottoman authorities, Layard finally sank a spade into the mound at Nimrud, 20 miles south of Mosul, in the summer of 1845. This is the site that, according to Iraqi officials, IS began bulldozing earlier this month.

Ancient Assyrian city of Nimrud

Nimrud covers some 3.5 sq km (1.35 sq miles), with a prominent "citadel" mound within the city walls

Main administrative and religious buildings include the enormous palaces of several Assyrian kings and the temples of Ninurta, the god of war, and of Nabu, the god of writing

The Palace of Ashurnasirpal, also known as the North-West Palace, was first excavated by Austen Henry Layard in the 1840s

Extended excavations were next carried out in the 1950s-60s by Max Mallowan, the husband of Agatha Christie

Unrivalled riches of Nimrud

On the first day of the dig, Layard found the outlines of a royal palace. A week later he was unearthing the huge slabs of alabaster that had lined its walls, panels that depicted the power of the Assyrian king and the grovelling submission of his enemies. Within three or four years, Layard had unearthed the civilisation of ancient Assyria - until then nothing more than a name mentioned in the pages of the Bible - and had filled the British Museum with sculpture and writing from the birthplace of urban civilization.

Published in 1849, his account of his excavations, Nineveh and its Remains, became an immediate bestseller.

But by his own admission, none of this would have been possible without Hormuzd Rassam.

The Englishman may have known how to get funding from the trustees of the British Museum, but it was Rassam who knew how to deal with the villagers of northern Iraq, and spoke Arabic, Turkish and Syriac Aramaic, the language of the Assyrian Christians. It was Rassam who knew how to haggle with a tribal sheikh, how to bribe a local governor with a gift of coffee, how to hire 300 workmen to drag a colossal statue of a winged bull down to the Tigris and float it on a raft of wooden planks and inflated goatskins.

Image copyright ALAMY Image caption A winged bull being excavated by Austen Henry Layard

Determined as they were, Rassam and Layard could not ship everything to the British Museum. Among the sites they excavated was the gate of Nergal in the northern wall of Nineveh - the same gate where an IS jihadi stood last month to film a tirade against the polytheism and idolatry of the pre-Islamic world.

The gate is flanked with what Layard described, in his 1853 book Discoveries among the Ruins of Nineveh and Babylon, as "a pair of majestic, human-headed bulls, fourteen feet in length and still entire, through cracked and injured by fire".

Known as Lamassu, these beasts were set into the gates of Assyrian cities to intimidate enemies and ward off demonic spirits. They did not ward off the vandals of IS, who broke the Lamassu's face with a pneumatic drill.

Image copyright Other

As they jointly brought Assyria back from oblivion, Layard and Rassam forged a friendship that lasted the rest of their lives. Where Layard - like so many European Orientalists - delighted in dressing up in eastern clothes, Rassam did his best to present himself as a Victorian Englishman. He rode across the plains of Iraq in a waistcoat and jacket. He converted to Protestantism, which he described as "the pure religion of Great Britain". He spent 18 months studying at Oxford, where he learned to ice skate and from where he wrote to Layard, "I'd rather be a Chimney Sweeper in England than a Pasha [lord] in Turkey."

The excavations were so reliant on Rassam that, when Layard retired from archaeology to become a diplomat and politician, the British Museum appointed the young Iraqi to continue the excavations alone. Returning to Mosul, he demonstrated an astonishing devotion to the interests of his adopted country.

Image copyright ALAMY Image caption Austen Henry Layard depicted in Oriental costume

Archaeology was central to those interests. Across the whole of the upper Tigris, the British were vying with the French for the antiquities of the ancient world. The first to excavate Nineveh had been a Frenchman called Paul Emile Botta, and, although he had suspended his dig to focus on the nearby village of Khorsabad, it was generally understood that the site remained within the French sphere of influence. Rassam, though, was on his home turf, right opposite the town where he had grown up. He was not going to see the treasures of Nineveh, like those of Khorsabad, shipped off to the Louvre.

Without any kind of official permission, and working under cover of darkness, Rassam had his team dig into the northern corner of the mound. In December 1853, about a week into the excavation, a huge bank of earth collapsed and Rassam heard his men shouting "Suwar!" - images. There, in the moonlight, were stone panels that had been carved more than 2,500 years earlier for the rooms of the Assyrian King Ashurbanipal (who ruled from 668 to 627BC).

Image copyright ALAMY Image caption Assyrian relief of lions being hunted

This was art of a breathtaking quality - scenes of a lion hunt across the plains of Mesopotamia, of the animals succumbing to the arrows of the king, scenes that held a pathos and a dramatic intensity beyond anything that had previously been excavated from the Middle East. "The lion hunt scenes date from the most developed period of Assyrian art," says Dr John Curtis, President of the British Institute for the Study of Iraq. "The lions are depicted in a wonderful way, full of life and naturalism. They are the finest products of Assyrian relief carving."

If it had contained nothing other than the lion hunt, Ashurbanipal's palace would still have been one of the most important archaeological finds of the 19th Century. But the floor of the palace was strewn with the broken remains of the king's library. "Amongst these records," wrote Rassam, "were found the Chaldean accounts of the Creation and Deluge." Rassam, although he didn't read cuneiform and didn't yet know it, had found the Flood Tablet.

The crates containing Ashurbanipal's library arrived in London around the time that the young George Smith was leaving school. Like Rassam, Smith was not a natural member of the Victorian establishment. Born into a working-class family, he was apprenticed at the age of 14 to a firm of banknote engravers. The boy was a fine draughtsman, but by the time he started work, his imagination had already been caught by the swashbuckling adventures of Layard and by the antiquities that were arriving from Nimrud and Nineveh. By the middle of the 1850s, Smith was hanging around the British Museum in his lunch hour, peering at the cuneiform tablets that had come from the palaces of the Assyrian kings.

By 1860, when he was 20, Smith had started to understand both the cuneiform script and the Akkadian language in which most of the tablets were written. A year later the museum's staff hired him to clean and sort the tablets. He had an astonishingly good visual memory, reassembling and deciphering lines of near-illegible text that were dispersed across hundreds of shattered fragments. It was not long before Smith, who had never attended a university and had never left Britain, was making major discoveries in the history and literature of the Assyrian empire.

Image copyright ALAMY Image caption Head of a winged bull from Nimrud, in the British Museum

Smith was gratified by the recognition of his fellow Assyriologists, but what he really wanted was something that would make his name with a wider public - something that might justify an expedition to Iraq. In November of 1872, as he spelled out the poetry of the Flood Tablet line by line, he knew he'd found it. Smith was so excited, wrote one of his colleagues, that he "rushed around the room" and "to the astonishment of those present, began to undress himself".

Two months later, with 1,000 guineas put up by the Daily Telegraph, George Smith was dispatched to Iraq to resume the excavations that had begun a generation earlier.

Lacking the flamboyance of Layard and the street smarts of Rassam, Smith struggled to cope with the heat and squalor of the Ottoman Empire. He was, says David Damrosch, appalled by the hygiene, revolted by the sight of a kebab, too naive to pay the small baksheesh that could have eased every transaction.

But there can be no doubt that George Smith was an out-and-out genius. By the time he died in 1876, wasted by dysentery in Aleppo, he had published eight groundbreaking books on Assyrian history and linguistics, made dozens of major archaeological finds, and rediscovered the world's first great work of literature. He was just 36 years old.

With Smith dead, Rassam was recalled to the service of the British Museum. He went on to find and excavate the Babylonian city of Sippar, to discover the great bronze doors of the palace of Balawat, and to send more than 70,000 cuneiform tablets back to London. These were discoveries that should have made him famous - but by the time of his final expeditions in the 1880s, Hormuzd Rassam was being erased from the record.

Image copyright The Trustees of the British Museum Image caption Hormuzd Rassam after he settled in England

Sir Henry Rawlinson, who had been British Consul in Baghdad at the time of Rassam's nocturnal excavations at Nineveh, now claimed the discovery of Ashurbanipal's palace for himself. Rassam, he wrote, was just a "digger" who had overseen the work. Even more insulting was the insinuation, made by one of the British Museum's curators, that Rassam had profited from the illicit antiquities trade that had grown up around the excavations in Iraq.

Hormuzd Rassam, who had been so impressed by the manners of the Victorian elite, and who had given his entire career to the service of the British Empire, was treated to a generous serving of snobbery, racism, and contempt. He could find no British publisher for his memoirs, and by the time he died at his home at Hove in 1910, even his name had been removed from the plaques and visitor guides at the British Museum.

The one Englishman who stood by Rassam was his old friend Layard. Rassam was, wrote Layard, "one of the honestest and most straightforward fellows I ever knew, and one whose services have never been acknowledged".

Image copyright The Trustees of the British Museum Image caption Austen Henry Layard

"Rassam is still remembered in Mosul," says Dr Lamia al-Gailani, an Iraqi archaeologist at University College London. "They are very proud of him."

In the UK, though, his reputation has never been fully rehabilitated. A generation after he left the field, archaeology developed into a disciplined, scientific search for knowledge rather than a greedy, imperialist scramble for treasure. Every handful of earth was now sieved, every seed and tooth collected, every shard of pottery measured and analysed.

Layard and Rassam, who had been paid by an imperial power to dig out the masterpieces of Mesopotamian art before the French, had gone shovelling through the mud walls of ancient buildings without even noticing them, had kept only the most rudimentary records, and had churned up sites that, explored with less haste and more method, could have yielded a wealth of knowledge about the lives of the Assyrians. By the standards of modern archaeology, they were not much more than treasure hunters in the pay of the British Museum.

Image copyright Getty Images Image caption Assyrian winged bulls at Iraq's national museum in Baghdad

"For Iraqis, of course, it's emotional," says al-Gailani. For a long time they've come to the British Museum and seen these antiquities, and they feel that they should be returned to Iraq. But at the moment they keep quiet. Because they see what's happening in Iraq, and they see that these things in the British Museum and in the Louvre have at least been saved."

Not everyone is so willing to exculpate the colonial powers. But for all the treasure that Layard and Rassam removed from Mesopotamia, there were lines that they did not cross.

On the smaller of Nineveh's two ancient mounds was a shrine that the locals called Nebi Yunus. It was the burial place, they said, of the Prophet Jonah. For centuries it had been a site of prayer and pilgrimage for Mosul's people, Christian and Muslim alike. Layard and Rassam knew that it stood above an Assyrian royal palace. But this was a sacred place, and it could not be disturbed.

IS, though, has no such scruples. On 24 July 2014, its fighters packed the shrine of Nebi Yunus with explosives and blew it to smithereens, sending a cloud of debris into the sky above Mosul.

Media playback is unsupported on your device Media caption The Shrine of Yunus in Mosul was targeted by Isis militants

Thieves working for Islamic State began digging into the ruins beneath the demolished shrine. According to Qais Hussein Rashid, Iraq's Deputy Minister for Tourism and Antiquities, artworks from the site have already been smuggled into the hands of private dealers in Europe.

There are hundreds of ancient sites now in the hands of IS. But beneath the rubble of Nebi Yunus is a stretch of ground untouched by archaeologists - ground that holds the palace of the Assyrian King Esarhaddon, and that might might contain some of the great artistic or literary treasures of the ancient world.

In all likelihood, we'll never know.

Subscribe to the BBC News Magazine's email newsletter to get articles sent to your inbox.