Sixty years ago, four months after British rule had come to an end in India, the Nizam of Hyderabad, then the richest man in the world, was still refusing to join the new Indian union. Sir Osman Ali Khan saw no reason why Hyderabad should be forced to join either India or Pakistan. His state, which had remained semi-independent within the framework of the Raj, had an economy the size of Belgium's, and his personal fortune was more remarkable still -according to one contemporary estimate, it amounted to at least £100m in gold and silver bullion and £400m in jewels. Many of these came from the Nizam's own mines, source of the Koh-i-Noor and the Great Mogul diamond, at the time the largest ever discovered. He also owned one of the Islamic world's great art collections -libraries full of priceless Mughal and Deccani miniatures, illuminated Qur'ans and the rarest and most esoteric Indo-Islamic manuscripts.
Partly because of this extraordinary wealth, the Nizam was always feted by the British as the most senior prince in India, and given precedence over his rivals. For more than three centuries, his ancestors had ruled a state the size of Italy as absolute monarch, answerable - in internal matters at least - to no one but themselves, and claiming the allegiance of up to 15 million subjects.
In the years leading up to the second world war, the Nizam was regarded by many as the leading Muslim ruler in the world. In 1921, his two sons had been sent to Nice where they married the daughter and the niece of Abdul Majid II, the last Caliph of Turkey. The Caliph had recently been expelled from the Topkapi palace by Atatürk, and sent into exile in France. As part of the marriage arrangements, the Caliph had nominated the Nizam's son as heir to the Caliphate, so uniting the supreme spiritual authority of the Muslim world with its greatest concentration of riches. The dynasty seemed unassailable.
Yet by the late 30s, more far-sighted observers realised that the Nizam's world could not last. "He was as mad as a coot and his chief wife was raving," I was told by Iris Portal, sister of the British politician Rab Butler. She had worked in Hyderabad before independence: "It was like living in France on the eve of the revolution. All the power was in the hands of the Muslim nobility. They spent money like water, and were terrible, irresponsible landlords, but they could be very charming and sophisticated as well. They would take us shooting, talking all the while about their trips to England or to Cannes and Paris, although in many ways Hyderabad was still in the middle ages and the villages we would pass through were often desperately poor. You couldn't help feeling that the whole great baroque structure could come crashing down at any minute."
Portal became friends with Princess Niloufer, the Nizam's daughter-in-law and niece of the Caliph. One day, the princess took her to see some of the Nizam's treasure which was hidden in one of the palaces. They went down a flight of stairs, past a group of Bedouin guards, and there at the bottom was a huge underground vault, full of trucks and haulage lorries. The trucks were dusty and neglected, their tyres flat, but when the women pulled back a tarpaulin, they found that they were full of gems, pearls and gold coins. The Nizam, fearful of either a revolution or an Indian takeover of his state, had made plans to get some of his wealth out of the country if the need came. But then he lost interest and left the lorries to rot.
The disintegration of the state, and the dispersal of the wealth of the Nizam, the seventh in his line, is one of the 20th century's most dramatic reversals of fortune. After months of failed negotiations, India invaded Hyderabad in 1948, replacing the Nizam's autocratic rule with parliamentary democracy. Twenty-six years later, in 1974, India abolished the Nizam's title - along with those of all the other princes - removed their princely state pensions and made them subject to crippling new taxes and land acts, forcing them to sell most of their property.
When the seventh Nizam died in February 1967, his grandson, Mukarram Jah, succeeded him, quickly finding himself enmeshed in debts and financial chaos. He had inherited a ridiculously inflated army of retainers: 14,718 staff and dependants, including 42 of his grandfather's concubines and their 100-plus offspring. The principal palace, the Chowmahalla, alone had 6,000 employees; there were around 3,000 Arab bodyguards, 28 people whose only job was to fetch drinking water and 38 more to dust chandeliers; several others were retained specifically to grind the Nizam's walnuts. Everything was in disarray: the Nizam's garages, for example, cost £45,000 a year to keep in petrol and spare parts for 60 cars, yet only four were in working condition, and the limousine supposed to carry the new Nizam from his coronation broke down.
Most debilitating was the legal wrangling initiated by the several thousand descendants of the different Nizams, almost all of whom claimed part of Jah's inheritance. Jah's father, who had been passed over in the will, and his aunt led the legal challenge. Even securing the smallest sum to live on proved difficult for the new Nizam: his vast inheritance had been distributed among 54 trusts, the control of which was disputed. From the beginning, he was reduced to selling jewellery and heirlooms to keep solvent.
Eventually, in 1973, disgusted by the weight of litigation and the bitterness of the family in-fighting, Jah relocated to a sheep farm in Perth, Australia. There, he donned blue overalls and spent his days under the bonnets of his cars or driving bulldozers. As his biographer, John Zubrzycki, put it in The Last Nizam: "His grandfather composed couplets in Persian about unrequited love. To Jah's ears there was nothing more poetic than the drone of a diesel engine."
Jah sacked most of the 14,000 staff he left behind in India, and divorced his first wife, the sophisticated Turkish princess Esra, who saw no reason why she should move to a remote Australian sheep station. Over the following two decades he married four more times. One of his wives, a secretary named Helen Simmons, died of an Aids-related illness in 1989, which led to intimate details of the marriage being splashed across Australian tabloids. All five of the marriages added to Jah's growing pile of litigation, as each successive wife demanded fabulous sums in alimony.
In his absence, Jah's unsupervised Hyderabad properties were looted and his possessions dispersed by a succession of incompetent, dishonest or unscrupulous advisers. When Jackie Kennedy came to Hyderabad on a private visit a few years later, she recorded her impressions of this collapsing and leaderless remnant in a letter to a friend: "We had an evening with the old noblemen of the court..." she wrote. "There were three ancient classical musicians playing in the moonlight, and the noblemen were speaking of how it was all disappearing, that the youth didn't appreciate the ways of the old culture, that the great chefs were being taken by the Emirates... The evening was profoundly sad. My son, John, told me the next day that the sons of the house had taken him to their rooms because they couldn't stand the classical music - and had offered him a tall glass filled with whisky and had put on a pornographic cassette in the Betamax, and the Rolling Stones on the tape deck. They wore tight Italian pants and open shirts..."
In 1997, when I first visited Hyderabad, the plundering of the Nizam's property was nearly complete. The drawing rooms of the city were still buzzing with stories of how precious jewels, manuscripts, Louis XIV furniture and chandeliers from the Nizam's palaces were available on the market, for a price.
Meanwhile, his various palaces were decaying - some sealed by order of court, some sold off or encroached upon. Between 1967 and 2001, the Chowmahalla estate shrank from 54 acres to 12, as courtyard after courtyard, ballrooms and stable blocks - even the famous "mile-long" banqueting hall - were acquired by developers, who demolished the 18th-century buildings and erected concrete apartments in their place.
I visited the huge Victorian pile of the Falaknuma Palace, just to the south of the city. The complex, which stood above the town on its own acropolis, was falling into ruin, with every window and doorway sealed by red wax. Wiping the windows, I could see cobwebs the size of bedsheets hanging from the corners of the rooms. The skeletons of outsized Victorian sofas and armchairs lay dotted around the parquet floors, their chintz upholstery eaten away by white ants. Outside, the gardens had given way to scrub flats, waterless fountains, and paint-flaking flagpoles at crazy angles. It was a truly melancholy sight: a derelict Ruritania.
In 2001, on another research trip to Hyderabad, I received a phone call from a friend. The first wife of the present Nizam, Princess Esra, had unexpectedly appeared in the city after an absence of three decades. With her, she had brought the celebrated Indian lawyer Vijay Shankardass. Esra, it seemed, had recently met her ex-husband at the wedding of their son, Azmet, in London. She was shocked to hear of the state of Jah's affairs: he had been forced to sell his beloved sheep farm and flee his creditors. A partial reconciliation followed, and Esra was given the authority by Jah to try to save something for their son and daughter before what little remained in Hyderabad disappeared, too. It was her intention to settle the many outstanding law cases, open the palaces and lease Falaknuma to a hotel chain. She planned to turn Chowmahalla into a museum.
Chowmahalla, dating from 1751, was one of the finest royal residences in India. After some negotiation, I was allowed to accompany the princess on her visit, and so was there at the breaking of the seals of some rooms that had not been opened since the death of the previous Nizam in 1967.
What we saw was extraordinary, as if we were in the palace of Sleeping Beauty. In one underground storeroom, thousands of ancient scimitars, swords, helmets, maces, daggers, archery equipment and suits of armour lay rusted into a single metallic mass on a line of trestle tables. In another, album after album of around 8,000 Victorian and Edwardian photographs of the Nizam's household was covered in a thick cladding of dust. A unique set of 160 harem photographs, dating from 1915, lay loose in a box. On the walls, dynastic portraits were falling out of their frames. In one room were great mountains of princely dresses, patkas, chaugoshia and salvars, drawers of Kanchipuram silk saris, and one huge trunk containing nothing but bow ties. There were long lines of court uniforms as well as sets of harem clothes once worn by the Nizam's favourite wives. Almost 8,000 dinner services survived, one of which alone had 2,600 pieces.
In the King Kothi palace, the Nizam's dynasty's complete correspondence since the mid-18th century filled three rooms floor to ceiling. When the archivists had been sacked in 1972, the archive, all 10 and a half tonnes of it, had been stuffed into the rooms and sealed. Other rooms were stacked with crates of French champagne.
It looked an impossible task even to begin to sort out the mess and dilapidation. Yet remarkably, six years later, the Chowmahalla is now open to the public and 1,000 visitors a day are streaming through. A massive conservation project, unique in India, has restored and catalogued the best of what remains. The result is little short of incredible.
In the story of how the Nizam's inheritance was saved, Esra's lawyer, Vijay Shankardass, plays the most extraordinary role. An urbane figure, Shankardass is the only lawyer who has both chambers in Lincoln's Inn and a practice in Delhi. He is renowned for being as clever as he is honest and, as the man who represents Salman Rushdie, he is also celebrated for his courage and tenacity.
I met him in the largest suite of Hyderabad's grandest hotel, which he has occupied intermittently since beginning work on the Nizam's estate in 1996: "I was contacted by Princess Esra's lawyers in England," he told me, "and asked if I could intervene in trying to sort out the jewellery trusts which the last Nizam had set up." His initial response had been: " 'No way - it sounds like a snake pit.' No other Indian royal family had this level of indebtedness and financial chaos..." Then he met Esra and decided she was a remarkable woman - "upright, straight, clear-headed and trustworthy. So I agreed to help."
It was Shankardass's amazing achievement to have persuaded all 2,740 claimants - legitimate and illegitimate descendants of the different Nizams - to agree to a settlement of the jewel issue. In the process he was regularly blackmailed and threatened, both by the Hyderabadi mafia and the claimants them-selves. Several threatened to shoot him; on one occasion his car was hijacked as he drove to the airport. "There were some extremely rough men among the sahibzadas [princes]," he said. "Undesirable characters - hollow, shallow and proud. I had to have a full-time guard for two years."
In the end, the Indian government banned the export and public auction of the jewels, which they rightly regarded as a national treasure, but instead agreed to pay around £40m for them - less than a quarter of the market value, but much more than anyone had expected from the government. Of this, just under half was to go to the Nizam.
Next, the 130-odd legal cases still outstanding against the Nizam were settled, and debts, then standing at around £3m, were paid off.
All this still left a considerable fund for Esra to invest in the restoration of the Nizam's properties. She has the same talent for picking honest and effective people to work for her as her husband once proved to have for employing crooks. To supervise the restoration of Chowmahalla she chose Martand Singh, chairman and one of the founders of Intach, the Indian National Trust: "The first time I saw the state the palace was in, I thought it would be impossible to save," Singh remembers. "I thought it was hopeless. After the Nizam sacked his 14,000 staff, it had gone to the dogs. Decomposition can set in very quickly in India - one monsoon can do it - and these properties had been neglected for 30 years. Most of the decay was actually cosmetic. From the start, Esra was completely positive. She asked, 'How long is this going to take?' 'Three to four years,' she was told. 'Too long,' she replied. 'I want it done in two.' And Rahul succeeded in two and a half."
The first task was to restore a service wing of the palace, which was turned into a scholars' retreat, where architects, urban designers, art and ceramic consultants, conservators, specialist carpenters, photographic experts, textile restorers, antique upholsterers and historians could be lodged while they worked on the different collections. A conservation laboratory and museum store area followed. By 2002, the largest team of restorers ever employed on an Indian restoration project was at work. The collection of arms, along with the best of the textiles, carriages and photographic records - including the harem pictures, published here for the first time - were ready for the recent grand opening of the Chowmahalla palacec.
Fifteen Urdu and Persian scholars are currently sifting through the Nizam's vast archives. Already they have stumbled across a major historical discovery: the Nizam's negotiations in the early 40s with the Portuguese to buy Goa and so provide his state with a port, and with it a real hope - never realised, perhaps thankfully - of remaining independent from India once the British finally quit India.
Last month, Princess Esra returned to Hyderabad from her base on an island off Istanbul, to oversee progress. She swept in, sari-clad, imperious, a flurry of energy, and as ever, everyone stood to attention. Long lines of unframed canvases were laid out along the corridors and she walked past them, giving an instant decision. "No, not that one. It's Venetian - I don't like it. Not that, either. Now look at that - the sixth Nizam out riding with the Kaiser - yes, send that off for restoration immediately."
I asked if, looking back, she had any regrets. "Many," she said. "If I had the head on my shoulders I have now a few years ago, I would never have let things get into the state they did. But I was too young. At the time it all seemed impossible - the law suits, the huge taxes, debts accumulating, criminal cases, people abusing the trust we had put in them. We had no ready cash, and the palaces seemed like white elephants. So we fled, and then terrible things happened. So much just disappeared - jades, miniatures, furniture, chandeliers..."
"And the Nizam?"
"He had a brilliant brain when I met him," she said. "He'd had the best education money could buy - Harrow, Cambridge, LSE, Sandhurst. But partly because of his diabetes he went into decline, and in the end really, well, disintegrated. Today he keeps to himself in Turkey. Lives simply, doesn't love extravagance. Lives in a two-room flat in Antalya, and spends his time exploring Roman ruins, going swimming... He's upset, of course - that he didn't achieve what he had hoped, and he feels awkward he let so much go. He wishes he had done things differently - but then that is true of most people..."
Esra's 47-year-old son Azmet, heir to the eighth Nizam, Mukarram Jah, hopes to come back to Hyderabad and take on what remains of the family role in the city. Bin Laden and the assorted Islamist extremists who hope to bring back the institution of the Caliphate are no doubt unaware that Azmet, the man who has the strongest legal claim to inherit the title, was until recently a Hollywood-based cameraman who has worked with Steven Spielberg, Richard Attenborough, Nicolas Roeg.
"I am planning to spend much more time here," Azmet told me. "The death threats and law suits that kept us away are cleared up now, and I have great affection for this place." He paused: "I am determined to maintain what has been saved. We'll not make the same mistakes again."
· William Dalrymple latest book is The Last Mughal: The Fall Of A Dynasty, Delhi, 1857 (Bloomsbury)