Her dream was to paint the electoral map of Scotland in Tory-blue, but Margaret Thatcher made Scots see red.

By the time she stepped down as Tory leader in 1990, she had polarised opinion in Scotland like no political leader before her.

The first time she visited, 3,000 people turned out to see her on a walkabout in the St James Centre in Edinburgh. Police had to hold back the curious and at least three women fainted in the excitement.

When she arrived at Edinburgh Airport earlier, a piper with an evident sense of humour greeted her with the strains of "A man's a man for a' that".

Later that day, February 21 1975, Mrs Thatcher went to Glasgow to rally her party.

The previous autumn's general election had seen the number of Scottish Tory MPs reduced to 16. Even though the overall number of Westminster seats has since been cut, that number would still be an almost-unthinkable luxury for the Tories today.

But back then this was considered dire for a party which at the start of 1974 had 21 Scottish seats, and in the 1950s managed to win about 50% of the vote.

"Turn the tide we must, turn the tide we can and turn the tide we will," she told the Glasgow gathering.

By the time Mrs Thatcher stood down as Tory leader, just 10 Scottish Tory MPs remained. Seven years later in 1997, that number fell to zero in a Labour landslide.

The party now has just one MP north of the border: Scotland Office minister David Mundell.

In between that 1975 debut in Edinburgh and her tearful departure from Downing Street, Mrs Thatcher became a hate figure for many in Scotland.

She bore the brunt of the blame for the poll tax, introduced in Scotland a year earlier than in England, and was vilified for presiding over an industrial shakeout that shed workers in their thousands from mines, steel plants and other traditional industries.

But her supporters argued she was giving the economy the unpalatable medicine it needed, and also point to victory despite the odds in the Falklands.

Through it all, Mrs Thatcher gave the impression of being baffled at Scottish opposition to her policies.

As she saw it, the apparent Scottish virtues of thrift, hard work and entrepreneurialism fitted her view of the world exactly.

She rejected charges that her policies were heartless and insensitive.

The gulf between people in Scotland and Mrs Thatcher was never more clearly seen than in a 1990 TV interview with Kirsty Wark. In her Home Counties tones, Mrs Thatcher repeatedly used the phrase "We in Scotland", oblivious to the incongruity.

It transpired later that Malcolm Rifkind, the Scottish Secretary, warned her not to say "You in Scotland" as that would sound like she was in a foreign country. This, he noted later in a New Statesman article, was a prime minister who once praised her loyal deputy William Whitelaw by saying: "Every prime minister needs a Willie."

Politically, a now almost-forgotten relic of the Thatcher era was the Tories' initial support for devolution.

On that first visit to Glasgow in 1975, she declared: "The establishment of a Scottish Assembly must be a top priority to ensure that more decisions affecting Scotland are taken in Scotland by Scotsmen."

By the end of 1976, this position shifted to being in favour of devolution but opposed to the plan of the Labour government.

Labour introduced a scheme but that fell with the 1979 referendum which required 40% of the electorate to approve it.

In 1988 Mrs Thatcher said in Dundee: "As long as I am leader of this party, we shall defend the Union and reject legislative devolution unequivocally."

Many have noted the irony that it was the creation of the Scottish Parliament in 1999 which enabled her party to re-establish a political toehold. Her policies may even have helped speed devolution along.

To some, failing to support devolution was tantamount to supporting the Tories, a party whose shortage of MPs caused it to struggle at times to even fill the ministerial seats of the Scottish Office.

But some Tories accused fellow Scots of having their cake and eating it: criticising Thatcher for the effect of her policies and voting against her party while privately calculating that English votes would secure her re-election, tax cuts and economic improvement.

The image of Mrs Thatcher as a pantomime demon figure came to a head in Glasgow in the 1988 Scottish Cup final.

Unions distributed red cards beforehand with instructions for fans to brandish them when she arrived.

She became a demon figure of another kind after her 1988 speech to the general assembly of the Church of Scotland. This has been depicted as her declaiming: "There is no such thing as society."

In fact she used that phrase in a Woman's Own interview the previous October.

Her speech to the Kirk said much the same thing but also invoked Biblical justification.

"The 10th commandment, thou shalt not covet, recognises that making money and owning things could become selfish activities," she told the assembled ministers and commissioners.

"But it is not the creation of wealth that is wrong but love of money for its own sake."

She also told them: "We are all responsible for our own actions. We can't blame society if we disobey the law. We simply can't delegate the exercise of mercy and generosity to others."

Nevertheless, it was the "no such thing as society" tag which stuck.

Five years later, long after her departure from Number 10, then Scottish Secretary Ian Lang said: "Whoever said there is no such thing as society was talking nonsense."

He said of Mrs Thatcher: "She had a task to do: to destroy socialism and all its works. She largely succeeded, and that destruction is apparent not just in Britain but around the world."

But it is now time for Conservatism to "advance again", he said.

With those words, the Thatcher era in Scotland was officially over.