Cape Town on Friday, 2 February 1990, 20 years ago today, was an extraordinary place to be. Everyone seemed to be there. The world's press had descended on South Africa's coastal capital in expectation of what would be the biggest news story of the year. Television cameras roamed the town, but as the day wore on they concentrated outside the State Parliament where a momentous event was expected to be announced. In Greenmarket Square and along Grand Parade in the heart of the city, wealthy young whites mixed happily with black demonstrators carrying the black, green and gold flags of the banned African National Congress (ANC) party. Archbishop Tutu was at St George's Cathedral with his flock, which included more whites than blacks, ready to celebrate a happening which he seemed to regard as the Second Coming.

What they were all waiting for was the release of Nelson Mandela, icon of the anti-apartheid movement for two decades, which President FW de Klerk was widely expected to herald that morning in the annual opening address to parliament, traditionally the occasion for big announcements in South African history. Mandela, it was generally hoped, would complete his long walk to freedom a few hours after that, and no newspaper or TV station could afford to miss it.

In fact de Klerk had no intention of freeing Mandela that day. He had something even bigger on his mind, something he knew would take even the keenest observers of his presidential style by surprise. As MPs, ambassadors and other dignitaries gathered for the formal opening of parliament, only a handful of cabinet ministers were in the know, and they had been sworn not even to tell their wives – de Klerk only confided in his wife Marike on the way to parliament that morning.

De Klerk, in the job since September 1989, was about to announce the official end of apartheid, the system which the National Party, which included his Afrikaner forebears, had given birth to 41 years before and whose brutality and injustice millions had demonstrated against in every capital in the free world. He wanted maximum impact and publicity for his speech, which he had been working on for months, and he didn't want the distraction of Mandela's pending release getting in the way of it.

"I had decided to play that down in my speech," says de Klerk in his Cape Town home 20 years later. "I knew the world's press was there, not because they wanted to hear me speak, but because they wanted to witness the release of Nelson Mandela. But I wanted them to focus on the fundamental decisions we had taken and to judge them on their merits, and not have the whole package overshadowed."

Mandela himself was the only man in the world, other than de Klerk, who didn't want him to be released that day. He wasn't yet ready for it, and told government ministers that he needed more time to prepare. After all, he had been in prison for 27 years – what was another week or two? But even he had no inkling of what de Klerk had in store for his party and people that day.

For years de Klerk's presidential predecessors had used their opening addresses for the purposes of bringing in and then strengthening the creeping laws of apartheid, which basically held that whites and blacks should live entirely separately, the whites in the rich lands of South Africa, the blacks in the desperately poor homelands carved out for them. To enforce the principles, the regimes of Hans Strijdom (de Klerk's uncle), Hendrik Verwoerd, John Vorster and, to a lesser extent, P W Botha, had brought in act after act which would eventually institutionalise one of the most repressive and hated regimes of the second half of the 20th century. It was in this hall, on this same occasion, that announcements heralded the Bantu Education Act, the pass laws, the banning of political parties, detention without trial, the death penalty just for "furthering the aims" of communism, the banning of free speech, restrictions on trade unions, and many others. Black Africans had basically lost nearly all of their human rights over that period.

Nothing in De Klerk's Afrikaner background suggested he was about to reverse all that. He had been in the job just four months and was still an unknown quantity, but what was known about him suggested he was no reformer. After a lifetime in the National Party (he was 54), he was generally regarded as on the verkrampte, or unenlightened, side of the party, although he always saw himself around the middle, neither verkrampte or verligte (enlightened), but certainly conservative.

"Negative expectations hinged on the fear that FW, far from being an innovator, was a hidebound disciple of apartheid," said his own brother, Willem, later. "He never formed any part of the enlightened movement in South Africa. It was even rumoured he had tried to put the brakes on all the reforms PW Botha had made."

Mandela later remarked that he placed no hopes in the address that day because de Klerk was "trapped in apartheid" and was too concerned that his power-base was being eroded by defections to the Conservative Party to make any radical moves.

None of them knew that for a year De Klerk had been working on a package of measures which, as he says now, "would go much further than anyone expected and was intended to gain the moral high ground". He had rejected the safer route of a gradual dismantling of the system basically because "the world would have thought we were playing games", and time was against him. The fall of the Berlin Wall at the end of 1989 was also a critical factor: "That took the sting out of the tail out of the Communist Party." It did the same for the ANC, many of whose leaders, including Presidents Mbeki and Zuma, had trained in the Soviet Union. De Klerk says his instincts were "to go for the whole package – as one of my colleagues advised, when you cut off the tail of the dog, better do it in one stroke".

He had become leader of the National Party exactly a year before when PW Botha, suffering from a major stroke, had reluctantly agreed to split his role, retaining the state presidency but giving up the party leadership. In the party election which followed, de Klerk ran as the centrist candidate, narrowly beating his verligte opponent Barend du Plessis (the real verligte candidate, the charismatic Pik Botha, who was much favoured by Western and African leaders, was eliminated in the first round). De Klerk's relationship with President Botha, never easy, soon deteriorated as the president became increasingly irascible as well as forgetful. Botha was ill, but stubbornly stayed, making de Klerk's life more and more difficult. "He was giving me the cold shoulder. I was supposed to be the third minister in the government but I was not kept informed of events: for instance I didn't know there had been secret meetings with Mandela until after I became president. As time went on, and Mr Botha became more ill and difficult, there was crisis after crisis. He began to forget things, agreeing to something in the morning and then saying he hadn't been consulted in the afternoon."

South Africa was heading for an election in September 1989, its last in the old form, and just three weeks before it, the Botha situation came to a head. The foreign minister Pik Botha, working hard to repair South Africa's desperate image with the rest of the world, asked de Klerk to accompany him on a visit to see Kenneth Kaunda, president of Zambia. He needed his support for the independence discussions on Namibia, which South Africa was about to give up after more than 70 years' rule. Pik believed he had the president's approval for the visit, but when Kaunda announced the date (August 28), PW hit the roof, accusing his two ministers of treason.

"PW was furious," says de Klerk ruefully. "He announced he would have to discipline us for doing it without his permission."

It was the final straw. De Klerk summoned all the ministers he could find to his house in Pretoria and asked for a united front to force the president to take sick leave. When he went to see Botha in Cape Town to tell him this, "he used the opportunity to give us a long lecture and called a full cabinet". It was to be his last. De Klerk opened the discussion in the cabinet on the part of the ministers, and presented the sick leave option, which he thought would be more palatable than the alternative, which would be a very public sacking (Botha had done much the same to his predecessor, John Vorster, 11 years before). "He went around the table and asked every member of the cabinet for their opinion, and everyone said they supported my proposal," says de Klerk. "He got cross and said he was as healthy as any of us, and many of us were taking more pills than he was. Then he went outside, and when he came back in he said, 'Gentlemen, I am resigning.'"

De Klerk was elected state president after the general election and was inaugurated, rather more modestly, on the same spot where Mandela would have South Africa's most celebrated inauguration five years later. The changes began immediately: he appointed the first woman ever to serve in a South African cabinet, and brought in a number of industrialists to help deal with an economic situation which was in crisis, largely a result of sanctions and piled-up debts. He also lifted the restrictions on protest marches, including a huge one led by Archbishop Desmond Tutu, and ended many of the petty restrictions of apartheid, including segregated beaches, parks, lavatories and restaurants.

A bolder move was the release of political prisoners, starting with Govan Mbeki, father of (President) Thabo Mbeki, followed by all the ANC leaders who had been imprisoned with Mandela in the so-called "Rivonia trial" in 1964. Soon the entire leadership – the actual ANC leaders, Oliver Tambo, and his deputy, Mbeki, were running the party from exile in Lusaka – was given its freedom, with the exception of Mandela. "Everyone behaved themselves, and there had been no return to violence," he says. The way was now open for the release of Mandela.

In December de Klerk sent for him and Mandela was smuggled in through the basement garage of the presidential office in Cape Town (later occupied by Mandela), and the officials withdrew to leave the two of them on their own. Each later recorded they sat for a moment "weighing each other up". Like everyone else, de Klerk had no real idea what Mandela looked like, because there had been only a few secretly snatched photos of him for 20 years. He found himself staring at a man much taller than he expected, slightly stooped with age (he was 71), and dignified, courteous and utterly self-confident. Up to this point he had regarded him as "a grain of sand trapped in the oyster", the almost mythical hero who had posed so serious an irritant to his predecessors. Now here he was in the flesh.

"So this," de Klerk recalls saying to himself, "is Nelson Mandela." By the end of the meeting he had come to a remarkably similar conclusion as Mandela, both later consciously echoing Mrs Thatcher's famous remark about Gorbachev: "Here was a man I could do business with." Next time they met, de Klerk promised, they would discuss his release.

Mandela for his part wrote to his ANC colleagues in Lusaka that he had "taken the measure of Mr de Klerk, just as I had with new prison commanders when I was on Robben Island". De Klerk, he wrote, seemed to represent "a true departure from the National Party politicians of the past". In short, he was a man "we could do business with".

They did not meet again until after de Klerk's opening address, but behind the scenes there was frenetic activity as negotiations for the release accelerated. Both men had separately, and for different reasons, decided there was no alternative but to talk. Mandela later recorded that "it simply did not make sense for both sides to lose millions of lives in a conflict that was unnecessary", while de Klerk had concluded that he could not win a military victory either and must negotiate with the enemy before the economy collapsed.

All of this was leading up to his 2 February speech, which de Klerk worked on in a long break over Christmas and the New Year at his holiday home in the seaside resort of Hermanus, east of Cape Town. Several weeks before, he had taken his cabinet for a bosberaad, a conference in the bush where for days they discussed and debated the increasing limited options facing South Africa and its ruling white government. Everyone now accepted there had to be change, and that it had to incorporate negotiations with the ANC. The reality of a full democracy at some stage in the future now seemed inevitable, but none of them had any inkling of how far de Klerk, who had made statement after statement saying he would not accept majority rule, would go down that road. Even he had not made that leap yet.

Walking on the beaches over Christmas, de Klerk reflected on the journey which had taken him here, and the rocky and uncertain fate which lay ahead. His Huguenot ancestors arrived in the Cape in 1686 and the story of the de Klerks since had been, as he says, "the story of the emerging Afrikaner nation". They were farmers who took part in the legendary Voortek, when their leader Piet Retief led his column of ox wagons over the Drakensberg Mountains to escape British rule. Three de Klerks died with Retief in the great kraal of the Zulu chief Dingane in 1837, an event so deeply embedded in Afrikaner culture that 16 December, the day of the massacre, was named "The Day of the Vow" or "Dingane's Day", which is still celebrated. His grandfather was twice captured by the British in the Boer War, and later became a founder member of the National Party in 1914. De Klerk's own father was a minister in Verwoerd's government, and FW himself became an MP at 37 and was appointed to Vorster's cabinet five years later. Nobody's Afrikaner credentials were stronger than his.

"For many years I supported the concept of separate states," he says now. "I believed it could bring justice for everyone, including the blacks who would determine their own lives inside their own states. But by the early 1980s I had concluded this would not work and was leading to injustice and that the system had to change. I still believed in 1990 that the independent states had a place, but in the end the ANC had put so much pressure on them that they didn't want to go on. Had we offered Buthelezi a Zululand with Richards Bay harbour, he would have accepted that. But the whites wanted to hang on to as much as they could and were too greedy."

He had, he says, "long come to the realisation that we were involved in a downward spiral of increasing violence and we could not hang on indefinitely. We were involved in an armed struggle where there would be no winners. The key decision I had to take now, for myself, was whether to make a paradigm shift." By the time he was back in Cape Town in early January, he had taken that decision.

He finally took the full cabinet into his confidence just two days before his speech, swearing them to secrecy which was vital if he was going to achieve his objective of maximum surprise and impact. His press advisers were told to play down expectations, rather than build them up. In the outside world, the only subject anyone wanted to talk about was Mandela's imminent release. The media was arriving in great numbers, including the biggest names in the business: Ted Koppel decided to broadcast his entire ABC Nightline programme from South Africa for a whole week, and famous anchormen, editors and correspondents all took up residence in the crowded city. It was slated to be the event of the decade – except it didn't happen that day. The media would have to sit around – no hardship in mid-summer Cape Town – for another nine days before Mandela walked free nine days later.

"We had planned for February 2 in great detail, and it is remarkable it didn't leak," says de Klerk now. "My objective that day was to convince both our friends and our foes alike that we had made the paradigm shift." That morning, he says, he awoke with a "sense of destiny – I knew South Africa would never be the same again but I also believed I was doing the right thing at the right time."

In the parliament, the public gallery was crowded, and television cameras relayed the proceedings live to South Africans who had stopped to watch and listen. De Klerk calmly waited while the speaker opened the session with the traditional prayer. Then he walked over to the podium where his speech was already in place and began, speaking half in English, half in Afrikaans.

When he sat down 30 minutes later, the ANC and 30 other political parties, including the Communist Party, had been unbanned unconditionally; the death penalty was suspended; the state of emergency was lifted; trade unions were allowed to function freely; all political prisoners were to be released immediately and restrictions on political exiles were lifted; and, perhaps most importantly of all, de Klerk opened the way for South Africa's first fully democratic election in 300 years by promising "a totally new and just constitutional dispensation in which every inhabitant will enjoy equal rights, treatment and opportunity".

He didn't mention Mandela until late in the speech and only then in terms of the potentially important part he could play in negotiations, and the fact that he had already declared himself willing to participate in peaceful discussions (Mandela, offered his release five years before on condition he renounce violence, had flatly refused). But now, de Klerk said, he had taken a firm decision to release Mandela unconditionally, but not yet: "unfortunately a short passage of time is unavoidable". That would be days rather than weeks, he indicated, to a huge groan from the press.

He ended with an impassioned invitation to the ANC and all the other parties:

"Walk through the open door and take your place at the negotiating table."

In short, in half an hour, de Klerk had announced a commitment to a full democracy, with majority rule in a unitary state which would include the homelands, an independent judiciary, a commitment to equal justice for all under a human rights manifesto, no discrimination, and a free economy. The entire edifice of apartheid, so hated around the world, had been dismantled in a single speech.

He didn't have to wait long for the reaction. The opposition Democratic party roared its approval while there was disbelief along his own backbenches and fury from the Conservatives. The veteran editor, Allister Sparks, given a preview of the speech earlier in the day, gasped: "My God, he's done it all." On the streets of Cape Town and in the townships, wild celebrations went on into the night. Newspaper sellers quickly sold out of the Cape Argus with its headline "ANC UNBANNED", while Tutu giggled: "Just wait till de Klerk sits down with Tambo. They will discover how South African they both are!"

Messages of congratulations began to pour in from world leaders: from Margaret Thatcher, one of the few remaining relatively sympathetic voices, and presidents Bush, Soares, Mitterand, Kaunda and the UN secretary-general, Perez de Cuellar. There were even rumours the Pope might pay South Africa a visit, inconceivable only an hour before (he never did).

Mandela, watching on TV, later remarked: "It was a breathtaking moment, for in one sweeping action he had virtually normalised the situation in South Africa. Our world had changed overnight." There would be no more arrests for being a member of the ANC, no more persecution for carrying its green, yellow and black banner and "for the first time in almost 30 years, my picture and my words, and those of all my banned comrades, could appear in South African newspapers".

Not everyone was pleased of course. The reactionary Conservative Party and the right-wing of his own party vowed immediate revenge and called for a vote of no confidence. Die Patriot, organ of the Conservative Party, accused de Klerk of treason and naïveté towards the communists, still its bête-noir. In far-off Pretoria and the Afrikaans heartland in the Orange Free State, there would be rallies where demonstrators chanted "Hang de Klerk, hang Mandela" and for good measure, in case they felt left out, "hang the Jews".

But the die was cast and there was now no going back. Three years later Mandela and de Klerk went together to Oslo to receive their Nobel Peace Prizes. And a year after that, South Africa got its first black president.

De Klerk today: Confidant to current leaders

FW de Klerk, now aged 73, lives in Cape Town with his second wife Elita, his comfortable house distinguishable only from his wealthy neighbours by the security guards who alternate between him and his fellow ex-president, Nelson Mandela. His big interest today is the Global Leadership Fund, which he founded five years ago with the object of improving political leadership around the world. Its membership comprises some 24 former world leaders, including Joe Clark (Canada), Michel Rocard (France), Mike Moore (New Zealand) and Jose Maria Aznar (Spain), an extraordinary network of former heads of government who want to give something back by way of mentoring, guiding and helping new leaders who have no experience of government or how to cope with the hundreds of international agencies who turn up to clamour for their attention. The GLF has no agenda, and seeks nothing back (it even pays its own expenses from donations), often encouraging leaders to take credit for initiatives it has created for them. Countries such as Colombia and East Timor have acknowledged the GLF's support, but for many others it remains confidential.

Apartheid: Its roots and demise

1948. After decades of conflict between gold and diamond-hungry Brits and Boers – and a rising nationalist movement headed by the African National Congress (ANC) – a policy of apartheid (separateness) is adopted when the National Party takes power.

1960. Seventy black demonstrators are killed at Sharpeville. The ANC, which has responded to apartheid with civil disobedience led by Nelson Mandela, is banned. The following year, Mandela starts a campaign of sabotage with an ANC military wing.

1964. After his arrest two years earlier and subsequent imprisonment, Mandela is handed a life sentence. He spends 18 of his 27 years in prison on Robben Island, where he studies law and seals his status as the hero of the anti-apartheid movement.

1976. Black anger boils over in riots that become known as the Soweto uprising – South Africa's largest and deadliest anti-apartheid protests. An estimated 600 people, including child demonstrators, are killed in clashes that rage for three weeks.

1990. A year after FW de Klerk replaces PW Botha as president and segregation begins to end, the ANC is unbanned and Mandela is set free. Nine days earlier, FW de Klerk announces the end to apartheid and the coming of a "new South Africa" to a stunned all-white parliament.

1994. Mandela becomes President as the ANC wins South Africa's first non-racial elections. The country is restored to the Commonwealth, sanctions are lifted and South Africa takes a seat at the UN General Assembly after an absence of 20 years.