Margaret Thatcher, Britain's only woman Prime Minister and its longest serving leader of modern times, died after suffering a stroke.

Baroness Thatcher, 87, who was known as the Iron Lady during her 11 years in Downing Street, had suffered from long-term ill health, but passed away peacefully.

The former Tory leader had been staying at the Ritz Hotel in London, a guest of the wealthy Barclay Brothers, former owners of The Scotsman newspaper, since December. She was diagnosed with dementia in 2008.

Her passing was confirmed in a statement issued by her friend, Lord Bell, at lunchtime yesterday.

David Cameron cut short a trip to Madrid to lead the tributes, describing her as a "great leader, a great Prime Minister and a great Briton".

The Prime Minister later made a statement outside No 10, where his predecessor had first swept to power in 1979, before winning landslides at the General Elections of 1983 and 1987.

The Conservative leader conceded she had "divided opinion", but added Mrs Thatcher had "loved" the UK and "served it with all she had".

He said Baroness Thatcher had "succeeded against all the odds" as the country's first female leader, adding: "She'll go down as the greatest British peacetime prime minister.

"Her legacy will be the fact she served her country so well, she saved our country and that she showed immense courage in doing so."

Flags were flown at half mast at Westminster, the Palace of Holyroodhouse in Edinburgh and Buckingham Palace.

Buckingham Palace said the Queen, who reportedly had, at times, an uneasy relationship with Mrs Thatcher, was saddened by the news.

Sir John Major, who replaced her in 1990 after she was forced out of office and left Downing Street in tears, said: "Her reforms of the economy, trades union law, and her recovery of the Falkland Islands elevated her above normal politics, and may not have been achieved under any other leader."

Former Scottish Secretary Lord Forsyth added: "Her greatest achievement was, with Ronald Reagan, to stand firm against the tyranny of the Soviet Union and play such a crucial part in the liberation of parts of Europe, which is why they love her in places like Poland."

He defended her record in Scotland, saying it was a "myth" she had used Scots as guinea pigs for the poll tax after it was introduced a year earlier north of the Border than in England.

However, Respect Party MP George Galloway took to his Twitter account writing: "Tramp the dirt down." He also said Baroness Thatcher had once called Nelson Mandela a "terrorist".

Former Prime Minister Tony Blair said she would be "sadly missed".

He said: "Even if you disagreed with her, as I did on certain issues and occasionally strongly, you could not disrespect her character or her contribution to Britain's national life."

Gordon Brown, who invited Baroness Thatcher back to No 10 when he was Prime Minister, said: "She will be remembered not only for being Britain's first female Prime Minister and holding the office for 11 years, but also for the determination and resilience with which she carried out all her duties throughout her public life."

As senior figures within his party attacked her record, Labour leader Ed Miliband paid tribute to Baroness Thatcher, saying that while she was a divisive figure she had shown "utmost courage and dignity" in her final years.

Chancellor George Osborne said: "Margaret Thatcher's belief in freedom and optimism about the future overcame all. Her determination is our generation's inspiration."

Deputy Prime Minister and LibDem leader Nick Clegg echoed that sentiment, saying: "Whatever side of the political debate you stand on, no-one can deny that as Prime Minister she left a unique and lasting imprint on the country she served."

Tory Cabinet minister Francis Maude said there was a side to Mrs Thatcher that few people saw. He said: "People who worked closely with her absolutely adored her. They knew just how personally considerate she was."

But former LibDem leader Charles Kennedy said her legacy in Scotland would "always be controversial".

The Labour party was split on the issue of Mrs Thatcher's legacy. While former leaders and Prime Ministers spoke of the force of her personality and the impact she had on political life, others hit out at her policies, accusing her of leaving the UK with a series of problems it is still struggling with today.

Neil Kinnock, who as Labour leader had attempted to replace her as Prime Minister, said: "I recognise and admire the great distinction of Baroness Thatcher as the first woman to become leader of a major UK political party and prime minister."

Former London Mayor Ken Livingstone, said her politics had been "fundamentally wrong" and blamed her for "every real problem" faced in the UK today.

Former Labour minister Clare Short described her record as "very bad". She blamed Mrs Thatcher for large scale unemployment and said a "better leader" would have brought the miners' strike to an end quicker.

In Northern Ireland there was also division over Baroness Thatcher's political legacy.

DUP First Minister Peter Robinson said that she was a "transformative and powerful" Prime Minister who had been "one of the greatest political figures of post-war Britain".

But Sinn Fein leader Gerry Adams said she would be "remembered for her shameful role during the Irish hunger strikes. Her Irish policy failed miserably".

Glasgow-born Andrew Thomson, Mrs Thatcher's election agent in her Finchley constituency helped her win the seat in the 1983 and 1987 elections. He said: "She was marvellous with people and a personal kindness. She would talk fondly about the influence of Scottish people in places like Canada, Australia and Hong Kong."

Ex-cabinet colleague Lord Tebbit said: "We could do with another one like her right now."

Mrs Thatcher's ex-press secretary Bernard Ingham said she was an outstanding PM, adding: "She was the perfect Prime Minister – she knew what she wanted to do, and did it."

Actress Meryl Streep, who won an Oscar in 2012 for playing Lady Thatcher in The Iron Lady said she was a "figure of awe".