Tony Blair made history five months after his 1997 landslide election victory when he met the leadership of Sinn Fein - the first prime minister to do so since David Lloyd George in the 1920s. The meeting was made possible after the IRA restored its ceasefire in July 1997:

Tony used to claim that every time he came across the Irish Sea it started to rain, but that this made you appreciate it even more when it stopped. When we crossed the channel on October 13, Northern Ireland looked beautiful from the air, in bright sunshine after the rain cleared. We had deliberately decided to hold the first meeting with Sinn Féin leaders in Belfast rather than London, to get over the hurdle of seeing them by doing it in as low-key a way as possible. And we combined the meeting with other commitments.

Our meeting with Sinn Féin took place in a little, airless room with no windows in Castle Buildings [at Stormont in east Belfast]. On their side were Gerry Adams, Martin McGuinness, Pat Doherty and Siobhan O'Hanlon, taking shorthand. O'Hanlon was believed to have been a terrorist leader. She had become a fiercely loyal member of Adams' inner team.

Tony shook their hands one by one but Alastair [Campbell], John Holmes [Blair's Northern Ireland adviser] and I had decided not to on principle. Both sides were nervous, with Gerry Adams' hand shaking slightly.

Adams started off the conversation with some rather wet jokes, including giving Tony a tiny harp made of Irish bog wood which he said he hoped was the only bit of Ireland he would keep. He then asked how it felt to be in power and Tony replied, rather shortly, that it was better than being in opposition: we wanted to make some changes. McGuinness interjected that they wanted changes too.

Adams said he wanted to avoid history lessons and then proceeded to give us one, the burden of which was that the problem had been caused by the British presence in Ireland. He said that John Major had made a mess of the peace process and that we had to pick up the pieces. He also emphasised how determined they were to avoid the republican splits that littered Irish history, and to keep the movement together. He didn't want to create an Irish Hamas.

McGuinness said Northern Ireland was a political problem, not a security one, and the dispute could only be resolved politically, whether now or in 25 years' time.

Tony spoke rather well, with passion. He stressed the importance of consent and of their commitment to pursuing their ends through non-violent means, and warned them that the whole thing would be off if there was any return to violence.

I recorded in my diary that they were much more articulate and interesting than most of the other Northern Ireland politicians. John Holmes thought they were distressingly stuck in a rut, but I found them more flexible than I had expected.

Tony did a brief press conference after the meeting and was asked if he had shaken Adams' hand. He had prepared his reply and said he had treated him as he would any other human being.

The meeting had been long on symbolism, being the first meeting between republican leaders and a British prime minister for 80 years, but light on substance. We hadn't really got a feel for their positions or even if they were serious about seeking peace, let alone why.

It was a curiosity to meet people who had been demonised throughout my adult life. Television had not even been able legally to broadcast their voices and so for years the slightly threatening, bearded face of Adams and the clear, chilling eyes of McGuinness had been overlaid by the voices of actors. Now we had heard their real voices.

There was still, however, another symbolic hurdle to overcome and that was a meeting with Sinn Féin in Downing Street. We put it off as long as we could but eventually we had to agree to see them on December 11. There was a huge sense of occasion and everyone in No 10, from the principal private secretary, the most senior civil servant, to the messengers who delivered the tea, had been talking about it for days beforehand. Some had said they would not talk to Adams and McGuinness, and others that they would not shake their hands as a matter of principle. Alastair had even sent me a memo proposing we put off the erection of the traditional Christmas tree outside the front door of No 10 which was due to happen that day. He did not think we wanted a picture of Adams and McGuinness in front of festive decorations.

When the day came, the banks of cameras outside Downing Street were even larger than on the day after the election. Mo [Mowlam, Blair's first Northern Ireland secretary] came into No 10 through the internal door from the Cabinet Office to avoid them. Sinn Féin arrived 10 minutes early with a big delegation and on Mo's advice we made them wait. It was with some trepidation that Tony and I together with Alastair, John Holmes and Mo hovered in the cabinet room in Downing Street waiting for Adams and McGuinness to be shown in with their delegation including Martin Ferris, a leading republican from the south and a convicted gun runner, Michelle Gildernew, Lucilita Bhreatnach, and Adams' two assistants, Siobhan O'Hanlon and Richard McAuley.

We waited on the prime minister's side of the cabinet table. Tony met them as they came through the door and shook their hands. Martin McGuinness came round to our side of the table to shake my hand, but I guided the others round to the opposite side.

A strong sense of the past hovered over the meeting. Before sitting down, McGuinness paused and observed: "So this is where all the damage was done."

We all froze, taken aback by this opening gambit, and I said: "Yes, the mortars landed in the garden behind you. The Gulf war cabinet on this side of the table, including my brother Charles, the prime minister's foreign affairs adviser, dived under the table, before retreating to the garden rooms below. The windows came in but no one was injured."

McGuinness looked hurt. "No, I meant this was where Michael Collins signed the treaty in 1921." We, with our shorter-term perspective, had been thinking of the IRA attack on Downing Street in 1991, while they, with their longer sense of historical grievance, had been thinking about the treaty of Irish independence signed with Lloyd George that had given rise to the Irish civil war.

Adams opened the meeting by referring to the pictures of past prime ministers in the hall, all of whose policies in Ireland had failed. He said he was grateful to Tony for taking the risk of holding the meeting and asked if the Labour party policy of unity by consent had disappeared altogether. What was the government's strategic view?

He did not want to appear to be lecturing the prime minister but his big fear was he would take his eye off the ball with all his other immediate preoccupations. Northern Ireland would be the most challenging test of his time in office. Tony said he would not be a persuader for a united Ireland but he did want to create a situation in Northern Ireland that was fair.

He asked if Adams could go back and tell his people there was no possibility of a united Ireland. Adams said the question was rather how he could bring his people along. He had to show them there was an alternative way forward.

McGuinness said the strength of the "securocrats" in the British system worked against the peace process: the prime minister had to change it.

Message to the press

Tony said he needed to look into Adams' eyes and hear him say that Sinn Féin were locked into the political process and would stick to their commitment to the Mitchell principles [of non-violence]. Adams said they were. At the end of the meeting we asked them what they would say to the waiting press when they went out on to the street. Adams said jokingly they would go out and say the prime minister had promised British withdrawal and that all the prisoners would be released.

As I wrote in my diary at the time, Adams seemed intelligent, subtle and impressive. He had stuck to the big issues and asked Tony to look beyond the current preoccupations in the talks and draw up a strategy for the future. Once the meeting was over, Adams came round the end of the table to where two pillars separate off part of the room, so other members of his delegation couldn't hear him, and said to Tony that he could of course split the movement any time we wanted him to, but that his aim was to carry them all along, and that he was at them persuading every day. Tony said he wanted longer and more informal discussions with Adams and McGuinness. After the meeting Tony said to John and me he was pleased that Adams seemed to accept he would have to live with something less than a united Ireland as the outcome of the process.

As they were leaving, Vera Doyle, a No 10 messenger from a border area of the Republic herself, came up to Adams and McGuinness and told them what she thought of the IRA. Despite that, they became firm friends, and they made a point of looking her up every time they came back to No 10.

Leaders of the IRA

Throughout the process that followed we had to deal with the duality of the republican movement. The IRA was a proscribed organisation and we could not talk to its leaders as such. Of course we knew some of the people we were talking to as Sinn Féin leaders were also leaders of the IRA.

And yet it wasn't as simple as the unionist claim that the two organisations were one and the same. In the early days I, like the unionists, would talk about the IRA/Sinn Féin in one breath. But the two organisations were different. There wasn't a complete overlap in their membership and their political imperatives were not the same. Some in the physical force republican movement were not politically subtle and some in Sinn Féin were not engaged in physical violence.

On a number of occasions during the negotiation Tony would offer to meet the high command of the IRA to try to reason with them himself. He was convinced that his remarkable powers of persuasion would succeed, but Adams would always say the time was not quite right, and maybe we should do it later.

As he explained to me after the negotiations were finished and devolution in place, it was only he and McGuinness who could persuade the leadership of the IRA. A direct meeting with Tony Blair would have undermined trust rather than built it. The theoretical division was also convenient for the republican leadership. As Mo observed in her autobiography, it gave them time to think, by saying they had to take their proposals away to consult the IRA on them, rather than having to come to a decision there and then.

Adams and McGuinness were determined to carry the whole movement with them rather than repeat the history of republicans, where any move forward had been accompanied by a split.

The difference was this time we were in the same position. We did not want to have to make peace lots of times with republican splinter groups. We wanted to do it once. And so, uniquely, the British government had an interest in a united republican movement as well, rather than trying to pursue a policy of divide and rule as it had in the past.

Ten years of work paid off on May 8 2007 when a grand ceremony was held at Stormont to mark the power sharing deal between Martin McGuinness and Ian Paisley. Jonathan Powell and Tony Blair found themselves sitting close to an interesting collection of republicans:

I would have felt it to be an even more remarkable occasion had I realised the identity of the group of middle-aged men sitting in the next section along in the gallery. They looked harmless enough with their grey hair, but they were in fact the high command of the IRA, who between them had served over 50 years in jail and been responsible for more than 1,000 deaths. It was only after the ceremony that we discovered who they were. Each of the key IRA figures were there, including the quartermaster general, the military commander in Belfast, the head of intelligence and the chief ideologue - all sitting in the gallery just a few feet away from Bertie Ahern and Tony Blair.

I had never met them and did not know what they looked like, but I felt I knew each one of them intimately. They had been the invisible presence at the negotiating table during all our talks.

They were the people Adams and McGuinness had needed to persuade to accept difficult compromises, usually going to meet them in an anonymous barn somewhere on the border with the Republic, in the middle of the night, with a running tractor engine in the background so their conversations couldn't be picked up. There was a powerful symbolism in the fact that these men, who had spent so much of their lives in hiding, had now come to witness openly the closing chapter of the long, drawn-out struggle.

There was another man who helped secure the final settlement. He was someone I had never met, and who was not well known to the public, but was also sitting in the gallery along with the other members of the republican leadership. Brian Keenan was at one stage the biggest single threat to the British state. He ran the IRA's mainland bombing campaigns (for which he served 18 years in jail) and had persuaded Libya's leader Col Gadafy to arm the IRA. But he was also instrumental in bringing the IRA round to the political strategy, and, as the secret intermediary with John de Chastelain, the Canadian general in charge of the international commission on decommissioning, was the man who had achieved the decommissioning of IRA weapons.

If he had been against it, it would not have happened. If he had died, it might have been impossible to persuade the IRA to trade the Armalite for the ballot box. He too looked frail, but he had lived long enough to politicise the volunteers of the IRA over time, and gradually to transform physical force republicanism into a political movement.

Jonathan Powell's CV

Born

August 14 1956, youngest son of Air Vice-Marshal John Powell and younger brother of Lord Powell of Bayswater, former private secretary to Lady Thatcher, and Chris Powell who ran Labour's advertising in the 1990s

Education

The King's School, Canterbury; University College, Oxford; and the University of Pennsylvania

Career

Started as a journalist with the BBC in 1978. Joined Foreign Office in 1979. Desk officer for negotiations over return of Hong Kong to Chinese rule and member of the "Two Plus Four" negotiating team on German unification. Made his name in Washington, where he served from 1991-95. Became Tony Blair's chief of staff in 1995, a position he held until Blair left No 10 last year

· Extracted from Great Hatred, Little Room by Jonathan Powell, to be published by The Bodley Head on March 20 at £20. To order a copy for £18 with free UK p&p go to our bookshop or call 0870 836 0875