One balmy summer night in August a man awoke in his home near the Turkish city of Izmit. Feeling thirsty and unable to sleep he roused his wife and they took coffee on the balcony.

Suddenly a loud and growing rumbling shattered the stillness of the early hours. The building shook and swayed and the couple had to grasp the parapet to avoid being hurled to their deaths.

As the terrible cacophony reached a climax, the ground beneath rose and fell in waves and the whole building began to fall forward. Thinking their end had come the couple prayed for deliverance.

Their prayers were answered. The front of the balcony softly touched the ground and the tilting ceased, allowing the pair to step off and run to safety.

The second they had left, the building suddenly came alive again, tilting backwards this time until it stood straight and proud once more. Then it collapsed like a pack of cards, killing instantly or incarcerating the dozens of less favoured families left inside.

An extraordinary scene, but just one of many played out on the night of August 17 1999, when a terrible earthquake, registering 7.4 on the Richter Scale, struck north west Turkey a hundred miles east of Istanbul.

Within seconds, tens of thousands of buildings were reduced to rubble or severely damaged, killing almost 20,000 people and injuring countless others. It was the 11th most lethal quake of the 20th century.

Economically too it took an enormous toll. Some estimates put the cost at more than 10% of Turkey's GDP.

The quake should have come as no surprise. The region around Izmit straddles the 1,600km long North Anatolian Fault, a weakness in the crust that mark's the boundary between two of the earth's plates.

Time and time again over the last hundred years this fault has ruptured, generating eight destructive earthquakes - in excess of magnitude seven on the Richter Scale - that have crept ominously closer and closer towards the great urban sprawl of Istanbul. Following the Izmit quake, and another almost as large that shook the Ducze region three months later, all the active segments of the North Anatolian Fault have now ruptured, except that beneath the Sea of Marmara - directly south of Istanbul.

Given this picture it is not surprising that the Turkish authorities and the population of Istanbul are seriously worried about the safety of this great city. Istanbul has been rocked before by major earthquakes - the last in 1766. Then, as now, the event was preceded by a sequence of quakes that worked their way along the North Anatolian Fault from the east, and another occurred in the Izmit region just decades before the last Istanbul quake.

Geologists point out that a 160km stretch of the North Anatolian Fault beneath the Sea of Marmara has been accumulating stress since 1766. This is sufficient to trigger a displacement along the fault of five and a half metres - easily enough to generate an earthquake at least as big as that which flattened Izmit last year.

It seems inevitable then that Istanbul will succumb to a major earthquake, possibly sometime in the next few decades. But how will it and its people fare? The omens from the Izmit quake are not good. Because of the continuous seismic threat, building codes are in force to ensure that structures are capable of surviving the magnitude 7 plus quakes that regularly rock the north of the country.

Unfortunately the Izmit experience showed that having the codes in place is simply not sufficient to avoid catastrophe. They must also be enforced. At Izmit and in the surrounding urban centres, thousands of apartment blocks that should have stood relatively firm were reduced to rubble with ease, burying all inside and yielding few survivors. It was not long before the reasons for this became apparent.

The building boom of the last few decades - driven by the rapid growth of the Turkish economy - had led to a proliferation of cowboy builders and methods. Cheap or inappropriate materials were used, walls and floors were not sufficiently tied together, and housing inspectors turned a blind eye - perhaps aided by a little greasing of palms - to what would turn out to be the lethal cutting of costs and corners.

In the aftermath of the catastrophe it was not too difficult to spot the irresponsible builders as little evidence of their labours remained. But among the heaps of rubble and bodies, some apartment blocks stood virtually untouched - testimony to the work of builders who gave more than a passing nod in the direction of the Turkish earthquake building codes.

Since the Izmit disaster, politicians in Turkey have been desperate to demonstrate to their people, and particularly the 12 million who live in greater Istanbul, that they regard the enforcement of seismic building regulations as of paramount importance.

One former Istanbul mayoral candidate - also an architect - whom I talked to during a recent visit was not, however, optimistic - pointing out that of the two and a half million buildings making up Istanbul around 80% are illegally or inappropriately constructed.

Even if more stringent seismic code enforcement does result in new buildings being sufficiently earthquake-proofed, there does not seem to be either the political will or the money to ensure the expensive retrofitting needed to make these huge numbers of older buildings safe during the coming quake. As earthquake engineers never tire of pointing out "it is buildings not earthquakes that kill people" so the future for inhabitants of the "gateway to Asia" looks far from rosy.

 The Izmit earthquake and the threat to Istanbul are addressed in the second programme of Bill McGuire's new Radio 4 series Disasters In Waiting at 9pm on Wednesday, April 26. Bill McGuire is the Benfield Greig professor of geohazards and director of the Benfield Greig hazard research centre at University College London. His new book, Apocalypse: A Natural History Of Global Disasters is published in paperback by Cassell at £14.99