My first face-to-face encounter with Margaret Thatcher came during that blistering summer of 1976. As a 22-year-old researcher, I was allowed to attend a shadow cabinet meeting discussing immigration policy. She had recently become leader of the opposition and was still surrounded by the "giants" from the Heath cabinet, men thought to be her intellectual and social superiors. A bell announcing a vote in the House of Commons interrupted proceedings. Chris Patten, as secretary to the shadow cabinet, said it was a motion to allow any turban-bearing Sikh to be exempt from the requirement to wear a crash helmet on a motorcycle.

"I must go," she said. "I am pledged to support them." One of the giants, Lord Carrington, muttered something she didn't catch. Like a schoolboy, he was made to repeat it. "I said it was ironic that here we are devising how to keep people out of the country, while you are off to vote for the Sikhs." Silence. "It was a joke." She looked at the former defence secretary as though he were a piece of dirt. "Well, it wasn't very funny. These people fought for us in the war, Peter, fought for us in the war. Have you got it?" And off she flounced to record her vote.

Everything you needed to know about her was revealed in that scene. She loved a row. Once she was in command, she felt no awe for anyone. She matched the social hauteur of the Tory grandees with her sense of moral superiority. Her grocer father had taught her right and wrong, and to stand up for what you believed in. She had backbone, which their species, she seemed to imply, had lost through years of interbreeding.

Generally she arrived at her opinions based on some simple principle. British history and her libertarian instincts had the strongest influence in forming those principles. That could lead to surprising attitudes. She was neither racist nor homophobic, nor even judgmental about people's private lives. She chose many Jews to serve in her cabinet and many gays. Cecil Parkinson's affair with his secretary worried but didn't disgust her. She had an extraordinary rapport with the Asian community, with whom she had some values in common.

Her schoolma'm manner was an effective tool. Before any meeting with her I would swot like mad to ensure I knew my brief, to no avail. Her technique was to ask some off-the-wall question you could not possibly have foreseen, and then, when you failed to have the figures to hand, to shake her head as though it was beyond her comprehension how anyone so lazy could be in her government.

She had an absurd interest in detail. When we were about to reform social security benefits, she asked me how we would explain the changes. As an eager parliamentary undersecretary, I said I had already written briefing notes. "Let me see," she said. She began to redraft them sentence by sentence, and in truth I had not written them well. "Thank you, prime minister, I'll redo them in line with your suggestions." But as I reached across the table to take back my sorry drafts, she clutched them more closely to her. "Look at this terrible sentence. I can think of a much better way to put it," she said, red ink now covering my efforts. There were several other ministers present smirking at my humiliation.

Writing a speech for her was worse. Whatever international crisis might be raging, she would devote long hours of the night to drafting her party conference address. When we were all half-dead from exhaustion, she would signal her thanks for our efforts by crying out: "Can't we find anyone who can write a speech? There must be someone on the Telegraph or Times!"

She had amazing stoicism, which saw her through the most harrowing times. I first encountered it in 1979, when I briefed her each morning for her general election press conferences. One day I told her of a bad opinion poll. It could have meant the end for her, consigning her to a footnote in history. She said simply: "I took no notice of polls when we were ahead, and I shall take no notice of them now."

Not since Churchill had any prime minister been called upon to withstand so much pain, and to take such tough decisions. She lost her dear friend Airey Neave to an IRA bomb. Later she bore with fortitude the carnage of the bombing of the 1984 Conservative conference in Brighton. After the blast had torn apart her hotel room in the night and killed more of her friends, she appeared on the platform promptly at 9am so as to deny the terrorists the satisfaction of disrupting that part of our democratic routine. Then they murdered Ian Gow. I suppose they wanted to kill her and her friends because she was such a rock of resistance to their methods.

She did not flinch when hostage-takers took over the Iranian embassy; most were killed by the SAS. She would not be blackmailed by hunger strikes, letting IRA terrorist Bobby Sands and nine others starve themselves to death. Later she acquiesced in Ronald Reagan's decision to bomb Gaddafi, and famously told George Bush senior not to go wobbly on her as he vacillated over ousting Saddam's forces, which had invaded Kuwait.

The Falklands war was the biggest test of all. On the day of victory, Michael Foot was magnanimous enough to congratulate her after she had borne a huge burden of responsibility pretty much alone. We mustn't forget what courage it required to send the task force. Since Suez, Britain had assumed it could do nothing but accept changes in the world brought about by others. The buzzwords had been pragmatism and compromise. And it wasn't like Iraq, where we tagged along with the Americans and the result was not in doubt. In the Falklands it was impossible to say if we would win or be defeated.

Margaret Thatcher was far from unfeeling. It was courage not insensitivity that carried her through. Before she became prime minister she asked me why in my briefings I always brought her bad news: "You are battering me. Don't you realise that, like other people, I need building up?" Was I ever so stupid as not to understand that? It's commonly thought that people in authority are surrounded by sycophants who never tell them how bad things are. What a joke. Knock-kneed courtiers are always at hand to tell them how bad it is. What people in politics need is a little encouragement to help them bear the insults and the slings and arrows of outrageous fortune.

The BBC cancelled Ian Curteis's play about the Falklands because it showed her in too good a light, writing letters to the bereaved relatives of servicemen lost in action. I know she did it, late at night after a day of stress at a level we cannot even imagine. It might seem absurd, but she also fretted about the horrendous poll tax bills received by people she knew, people she knew couldn't pay. She blamed incompetent ministers and cynical local authorities for the charges, but still felt responsible.

No politician has ever faced such abuse.She was widely loathed. Fortunately, she had the ability, which John Major lacked, not to read what journalists wrote about her. Her press chief, Bernard Ingham, fed her summaries, not press cuttings. She was always the victim of snobbery. She was patronised by the broadcast media. The BBC found her vulgar and lacked the imagination to understand why the voters kept returning her to Downing Street.

It would be a mistake to forget herextraordinary instinct for the concerns of the upper working class. Her policy of selling council houses built a constituency of property-owning Thatcherites. She stayed in touch with the cost of living. She once recited to me the price of every brand of butter, Anchor, Wheelbarrow (Denis's favourite) and Lurpak. Shortly after I entered parliament she greeted me at a social function and asked me what was occupying my mind at the time. "Mainly the Gas bill," I said, because I was on the committee considering the legislation to privatise British Gas. "The gas bill?" she queried, a little puzzled. "Yes, I suppose that would be a worry at this time of year." Even in her fifth year in Downing Street, "gas bill" was more likely to mean a domestic invoice than the flagship of her legislative programme.

Years later I was the minister responsible for taxis. Minicabs were unlicensed and some lobby groups wanted them vetted. But the drivers of London taxis didn't want that, in case it made the minicabs respectable and so more competitive. A lot of the cabbies lived in Margaret Thatcher's Finchley constituency and they lobbied her. When she next saw me at a ministerial meeting, she hissed: "I hear you are thinking of legislating on taxis." As I began a reply, she pinned my hand to the table with hers, as though she thought I might otherwise try arm-wrestling her. "Drop it," she barked. I agreed and she let me go.

Neither was she pigheaded. Her spin built up her reputation for never swerving. The reality was different. Sometimes she hesitated and was nearly always cautious. During the runup to the 1979 general election, when commentators were obsessed with how a Tory government would get on with the trade unions, she crazily suggested she might get out of a deadlock by calling a referendum. The answer carried overtones of Edward Heath, her predecessor as leader. He had called the February 1974 election in the midst of a coal strike on the slogan "Who governs Britain?" and lost. In 1981 I was present when Margaret Thatcher gave the instruction to buy off the National Union of Mineworkers to stop the strike that had erupted. Her industrial relations reforms proceeded one careful piece at a time and most are still in place.

When the No Turning Back group (of Tory young Turks such as me) urged her to adopt our idea for grant-maintained schools, she pooh-poohed our political naivety (before eventually adopting the policy). Even privatisation was something unplanned. She saw the need to sell British Airways only when the airline needed approval to buy the new generation of 747s, which could not be afforded within government borrowing limits. The legislation to privatise British Telecom passed only in her second term.

Of course she foresaw the struggle with Arthur Scargill, a man bent on using industrial unrest and violent protest to bring about political change. The hard left rejected the emphatic verdict of the 1983 general election, which had given the Tories, with their commitment to trade union reform, an overall majority of 144. But many miners wanted to work, at first mainly in Nottinghamshire but later all over Britain. The right of people to get to their jobs unimpeded had to be upheld. Intimidation had to be resisted. It was a time when the nation was divided, but the undemocratic left had to be held in check and Thatcher's firmness has paid dividends for this country's economy since. We have never again been regarded as the sick man of Europe. Of course, the decline in the number of British pits – the ostensible cause of the strike – has continued ever since under Labour as well as Conservative government. But the economic changes that she drove through have enabled Britain to generate millions of jobs that respond to new markets.

The left rejoiced when she remarked "there is no such thing as society". It seemed to sum up all that her enemies believed of her, and provided a stick with which to beat her. Her meaning was the opposite of what the left claimed. She was objecting to people who used society as an excuse for ignoring their own responsibilities, as when they complain that society shouldn't allow a particular misfortune, while doing nothing to make things better. But, she argued, we are society. It is our responsibility to change it for the better. We are all role models for someone, in our families or communities. Thatcherism emphasised the role of the citizen rather than the role of government in making society better. But it was not a creed of individualism, because she emphasised every person's obligations to neighbours and the wider community.

I viewed the Thatcherite social revolution as having two parts, but admit that only the first was achieved. First, people were to be allowed to keep more of their own money, through lower taxes on income, and correspondingly the state would do less. That she accomplished. Second, she intended that citizens should take much more responsibility. Those who became successful would be expected to do more for their communities. The altruistic tasks they took on would not only provide more efficient services to the public than the state could accomplish, it would also create better citizens and a healthier society. Of course, we remember the greedy people who emerged during the Thatcher years (the "loadsamoney" syndrome) and that damaged her. But she certainly did not approve of them. I have to admit to Margaret Thatcher's failure to complete her revolution. But she believed in a person's inalienable obligation to society.

She was not much of an American poodle, at least by comparison with modern British poodles. She defied Jeanne Kirkpatrick and Al Haig who wanted her to settle with the Argentinian dictator General Galtieri at too high a price, she rowed with Reagan over his invasion of Grenada and was deeply anxious about his bombing of Libya. She was appalled at the concessions of balanced total nuclear disarmament that Reagan offered the Soviets at Reykjavik.

Mikhail Gorbachev found it necessary to talk to her precisely because she had such influence over Reagan. Looking back, she paid tribute to Reagan as the man who won the cold war (and it was won). His decisions to match the deployment of Soviet SS20 missiles in eastern Europe with cruise and Pershing missiles in western Europe, and to pursue the strategic defence initiative ("star wars") pushed the USSR out of the arms race and into despondent self-doubt. Reagan foresaw it, which probably she didn't. But without her, he might have let the victory trickle away with his ill-thought-out vision of a world free of nuclear weapons, as though they could be disinvented.

Margaret Thatcher became a global superstar. Two months before the general election of 1987, she did a walkabout in Moscow and was mobbed by a cheering crowd. After that, the British general election two months later seemed a waste of time. She was at her peak and Neil Kinnock, the Labour leader, was a pygmy by comparison.

She had understood charisma from the moment she became leader of the opposition. I was sent to assist at a byelection in Cambridge in 1976. She was to visit for a morning's campaigning. In the dark and cold we awaited her arrival at the Coach and Horses in Trumpington, where she was to exchange her official car for a party vehicle. Through the fog we heard roaring engines, then the car park was filled with vehicles screeching to a halt, doors flying open like a scene from The Sweeney. From one of them she burst, roaring: "Take me to the battle!" It was electrifying. When she canvassed, she ran up every street and every path, adrenalin pumping. When she entered a room and you had your back to her, you knew she had entered.

Her behaviour with her European counterparts mirrored her treatment of the Tory grandees. Her demands for a refund on Britain's budget contribution outraged them, and indeed the Foreign Office. Her report to the Commons after the Rome summit of 1990 (in which she listed the demands of other European states and yelled out her response: "No, no, no!") led Geoffrey Howe to leave the government and make his lethal resignation speech. That in turn encouraged Michael Heseltine to stand against her for the leadership and that way lay her demise. But it has amused me in later years to see John Major and Tony Blair set off for Europe with boy scout enthusiasm, merely to end up as disillusioned with the European carry-on as she had been.

Most of her cabinet ministers came to see her as unreasonable. They had tired of her rudeness and tantrums. They thought her an electoral liability. I didn't see things that way. Some of her colleagues behaved outrageously. Howe and Nigel Lawson threatened to resign if she wouldn't announce a date for British entry into the exchange rate mechanism at the Madrid summit in 1988. Whatever the merits of their argument (very few, I think) was it reasonable to blackmail a prime minister in that way? Not surprisingly, she decided she would have no reason to lament losing them, but they would have to be let go one by one and when the time was right.

The ousting of Margaret Thatcher was not only deplorable but also unnecessary. Panic had gripped the party because of the poll tax. As the minister most closely involved with local government, I was already working on far-reaching changes to the community charge, of the sort that we later introduced, dressed up as the new council tax. I believe she would have accepted those changes, even if she had forced us to preserve the name community charge.

On the night of Tuesday 20 November 1990, rumours swept Westminster that the prime minister was considering resignation. She had failed to win sufficient votes to avoid a second ballot against Heseltine in the leadership election. I was carried along with a band of loyalists to her room in the Commons. It was clear she had been crying and she heard us virtually in silence. In that group I was the only minister, albeit a junior one, and she asked me to stay after the others left.

She asked why I thought she should stay when most of the cabinet thought the game was up. I knew that she had not campaigned to retain her job. She had not made a single call to a colleague, thinking it undignified for a prime minister. I told her that she had many favours to call upon and many would crack if she stared them in the eye and asked for their support. The look she gave me then horrified me, because it told me that until that moment the idea of campaigning had simply never occurred to her, and now it was too late. In the morning, she announced her resignation.

The following Monday, she invited the young Thatcherite ministers in her government to a farewell Downing Street lunch. As we said our goodbyes, that group of junior ministers was overcome with grief and began to blub. Outside the dining room we met Denis, who looked at our red eyes askance. "We're not dead, you know!"

On her last full day in office she replied from the dispatch box to a motion of no confidence put down by Labour before they knew of her forced retirement. She gave a spellbinding performance. She laid about her with the self-assurance of one who had dominated the Commons for more than a decade. She squashed every criticism. She engaged in a good-humoured spat with Labour MP Dennis Skinner. As she neared the last moments of her premiership, she cried out: "I'm enjoying this." No matter how many tears she shed in private, in public her stoicism had not deserted her. It was certainly the greatest hour of my time in the House of Commons. Tory MPs gawped at her in awe. Across many of their faces you could read the horror of the unspoken question: "What have we done?" Some wept audibly and visibly.

I have few special insights on Margaret Thatcher's relationship with her husband. Everyone knows how important his support and opinion were to her. It was perhaps a more equal relationship than people might think, seeing her as a global figure and Denis often as a figure of fun. I remember him telling me of when, long before she became prime minister, Margaret had first thought of living in Flood Street in Chelsea. Denis had said: "Oh no dearie, we couldn't possibly afford that." His tone conveyed to me that he was the breadwinner and she had little understanding of money matters. His dependable Tory instincts provided her with a compass. In retirement, shortly before his death, he seemed to be supporting her in her infirmity rather than the other way around, though he was 10 years older.

It will be clear that I remain a great admirer of Margaret Thatcher. I believe her achievements at the time were extraordinary and extraordinarily beneficial to Britain. It's difficult to appreciate the difference she made unless you can remember how Britain was in the late 1970s. We were plagued by strikes. Britain seemed ungovernable. We watched helplessly as other European countries improved their living standards above ours. You could wait six months to have a telephone installed, unless you bribed the engineer. Our last notable foreign affairs venture, Suez in 1956, had left us humiliated. It had increased our post-colonial guilt and resulted in foreign policy paralysis. Britain was viewed as a depressing has-been of a country.

Bringing common sense into industrial relations was a huge boost to our economic revival, even though the necessary defeat of Arthur Scargill was bitter. Cutting income tax stimulated enterprise. Privatisation ended the shortages, broke up the monopolies and brought the prices of the utilities tumbling. People who bought their council houses felt a surge in their self-esteem and personal wealth. After the Falklands, Britain attracted international respect.

Before Margaret Thatcher, it would have seemed inconceivable that Britain could play a pivotal role in influencing the US. She really was key to the defence policies that shook the Soviet Union until it toppled. Without her pressure, the US might not have expelled Saddam from Kuwait. I have the feeling that Tony Blair asked himself every day in office: "What would Margaret Thatcher have done?"

She did the dirty work Britain needed to drag it out of decline. Those who refused to recognise tough remedies were required despised her and the Blairites have been reluctant to admit how much they owe her. Destroying the left was her greatest domestic achievement. Ironically, it paved the way to New Labour and to the worst period for the Tories since the mid-19th century.

She defined herself often by the things she was against. After 10 years she had defeated most of them, leaving the Conservatives uncertain what to turn to next. In any case, people had tired of combative rhetoric and wanted softer platitudes. There were those who reviled her and perhaps they will despise her memory. But her passing will allow for a more objective and positive appraisal of Britain's debt to her. Few prime ministers have been called upon to change so much. Few have been loathed as much for trying. Few have shown such courage.

Michael Portillo was transport minister and local government minster under Margaret Thatcher

Andrew Sparrow's rolling coverage of the day's political developments as they happen, including Lady Thatcher's coffin coming to the Commons and a debate on planning which is expect to see Tory MPs rebelling against the government