When the newly arrived ambassador to the United Nations from China recently spoke up in the Security Council against funding the rapid reaction force in Bosnia, he was instantly swatted by his colleague from Britain, Sir David Hannay. Since Peking continued to get away with contributing considerably less than it might to the UN budget, he suggested curtly, it would be better if it desisted from making any comment when it came to dollars and cents.

Even those well acquainted with Sir David's often bullying tongue were taken aback by the intensity of the assault. "I must say," the French ambassador whispered in his ear at a lunch meeting afterwards, "your aggressing of our friend from China was quite something". Sir David, certain this was a compliment, chuckled with evident satisfaction. So what if China is also a permanent member of the Council and the world's most populous nation?

For five years this has been the style of Sir David, who this week bowed to the Foreign Office's strict retirement rule of 60 and bade farewell to New York and his diplomatic career.

His impatience with those he considers less intelligent, less diligent or less informed than himself is legend at the UN. He was once heard to refer to one representative from Bonn as "that Teutonic turd". Nor was he any more merciful to his staff at the British mission. A book was kept among his underlings on who could elicit the longest stream of "noes" from Sir David in one go. It has finally been closed. The winner had 14.

He has been feared by almost everyone, but likewise he has been held in awe. Tangling with him was never advised, but having him on your side in a fight was invaluable. In his five years here, he has come to dominate the Security Council. Even he would never pretend that Britain could be the equal of the United States in diplomatic might, but as to the personalities in the chamber, he, not Madeleine Albright, has been the leader. Even for the drafting of tricky passages in resolutions, that must be both legally and politically effective, it was to Sir David they would turn.

But there was at least one person who could return to Sir David as good as he gave: the former Prime Minister, Margaret Thatcher. He volunteers the story of a pre-posting visit he paid her shortly before his transfer to Brussels as ambassador to the European Community, as it was then, in 1985. He suggested that representing Britain in the EC would be much like a game of snakes and ladders. He would endeavour to climb the ladders but sometimes, inevitably, he would slide down some snakes too. "No, David," Mrs Thatcher apparently replied. "That is where you are quite wrong. In Europe, they are all snakes."

It was from Brussels that Sir David switched to the UN in 1990. Ironically, he was displeased with the transfer, fearing that after six turbulent years at the EC, New York might prove rather boring and, worse, far removed from the domestic political scene. But once at the UN he was plunged immediately into the crisis of the Gulf war. There he was again, on the television news nightly, batting out his pithy one-liners for CNN and the BBC against the dictator in Baghdad. He was never happier.

Reflecting on his career during a farewell interview with the Independent, Sir David unhesitatingly identified the Gulf war as an episode of which he is especially proud. Early on in New York, he found himself as President of the Security Council at a critical period when harsh action by the Israeli government against Palestinian rioters almost destroyed the allied coalition against Saddam Hussein. His role in keeping the alliance intact was vital.

"The war was a turning point of the UN," he says. "And it was a remarkable episode in the twentieth century that has been more noted for failure to reverse aggression than success, and which has been marked by massive conflicts when the initial failure to reverse aggression has had to be corrected. The Gulf war did all that, just as it should have been done."

Bosnia, by contrast, is the conflict over which the UN has returned to type. He admits distress but not error on his part or of the Council. "The Bosnian poison has circulated in the veins of this organisation as it does in the veins of Nato and the European Union. And it is very debilitating," he says. "But it is not, in my view, a deadly poison. It is not going to kill any of these organisations. But they are going to be badly damaged by it." He is particularly distressed by the the strains it is bringing to Anglo-American relations.

While his usual confidence - arrogance, some might say - has visibly ebbed in recent weeks over the policies pursued by the West in Bosnia, he still believes them to have been basically the right ones. Containment remains, he says, the only option. Withdrawing the UN and supplying the Muslims with arms would be catastrophic. "I think it's a very bad policy option. I think it is a solution of despair to withdraw and lift the arms embargo. I don't think it's a real policy option and I think that the consequences of it would lead us down the road to probably even greater, more costly and less promising involvement, than the one we have now."

His six years in Brussels were barely less eventful. There was the warfare between Lady (then Mrs) Thatcher and Jacques Delors, which he now admits was damaging. And he was disappointed with the Prime Minister's infamous Bruges tirade against Brussels, because while it contained much wisdom it was also too vindictive. "It was blunted by the amount of straightforward commission-bashing that went on."

And we now know of the key role Sir David played in persuading Lady Thatcher to accept in 1985 the Single European Act, the rewriting of the Treaty of Rome that extended majority voting to ensure completion of the single market. "It was a difficult question as to whether we should concede to treaty changes. But it was certain in my view and in the advice that I gave that we were not going to get the single market without them."

But from now, no more for Sir David the dramas of emergency Council meetings and summits, or the flattery of the BBC. As he leaves, first to travel by train in China and then maybe to write a book about his time in New York and Brussels, he laughs out loud at perhaps the best last joke of his five years at the UN. Nizar Hamdoon, the Iraqi ambassador, actually took him aside the other day to say that his country would miss him. Maybe.