LONDON, NOV. 22 -- Margaret Thatcher, faced with the prospect of a humiliating defeat in a contest for leadership of her bitterly divided Conservative Party, called an end to a remarkable era in British politics today by announcing her resignation as prime minister.

Thatcher, who had insisted adamantly Wednesday that she would run in a second round of voting against party rival Michael Heseltine, changed her mind overnight after a parade of cabinet ministers told her in individual meetings that they believed she would lose. Some even told her they would oppose her, according to party sources.

Thatcher told the cabinet of her decision at 9 a.m., then released a statement saying: "I have concluded the unity of the party and prospects of victory in a general election would be better served if I stood down to enable cabinet colleagues to enter the ballot for the leadership."

Aides said she read the statement to the cabinet and then added with eyes glistening: "It's a funny old world that here I have won a majority of my party, and yet I feel I have to go." Thatcher, the only woman ever to serve as British prime minister, held the office longer than anyone since the Victorian Era and for more years consecutively than anyone since the Napoleonic Age.

Her resignation marks the close of a historic 11-year rule in which Thatcher, the unyielding apostle of free-market economics and a strong defense, not only changed the face of British society but wielded enormous influence in world affairs. It also set off a new race for leadership of the party and of Britain, as the cabinet's two senior members, Foreign Secretary Douglas Hurd and Chancellor of the Exchequer John Major, both announced they would run against Heseltine in a three-way contest Tuesday in the party's 372-member House of Commons caucus. As leader of the majority party, the winner will automatically serve as prime minister.

All three candidates are expected to continue many of Thatcher's policies -- including Britain's commitment to supporting Western military intervention in the Persian Gulf crisis. That commitment was underscored today as the government announced it will send 14,000 more troops and more combat aircraft to the region.

An elated Heseltine, now believed to be the front-runner in the contest to succeed Thatcher, told reporters: "This brings to an end a quite remarkable premiership. She has made a remarkable contribution to Britain's history and has led this country with distinction in the 1980s."

Other opponents were less conciliatory. Labor Party leader Neil Kinnock, described the news as "Good, very good indeed; I cannot pretend otherwise. . . . It's news that I've been waiting for and many people have been waiting for a long time."

Jack Straw, Labor's education spokesman, was more vituperative. "To have gotten rid of that evil woman after all the damage she has done to this country is simply wonderful," he said. "Now we're going to get rid of the rest" of the Conservatives.

But there was even more recrimination and anger from Thatcher loyalists who felt their leader had been betrayed. Alan Clark, a deputy defense minister, told reporters: "I think it's a disgrace, a real tragedy. We've lost the finest prime minister in 100 years -- not at the hands of the electorate but at the hands of a cabal." He called those who had opposed Thatcher cowards, saying "they did it because they're trying to save their seats, and most of them hid behind a cloak of anonymity."

Former party chairman Norman Tebbit, who said he had urged Thatcher to fight on against the odds, declared, "The party feels very sick, very guilty and very ashamed at what it's done." But Ivor Stanbrook, a Tory lawmaker who backed Heseltine, said he felt "great relief" over Thatcher's resignation. "I think she spared the party and the country a great deal of embarrassment and sadness. She made tactical mistakes. She took it for granted she was indispensable, which of course she wasn't."

Thatcher beat Heseltine in the first round of the caucus contest Tuesday by 204 votes to 152, but she failed to win the 15 percent margin she needed for outright victory. When the result was announced and stunned Tory lawmakers realized she had fallen short, her support began to melt away. Many believed that even if she won the next round, she would appear so crippled politically that she would drag the party down to disaster in the next general elections, which must be held by the summer of 1992.

Parliamentary sources said that both Hurd and Major were instrumental in persuading Thatcher that she was likely to lose next Tuesday's round to Heseltine, her most bitter enemy within the party since he stormed out of her cabinet in protest nearly five years ago.

Thatcher did not endorse any of the three candidates today, although many analysts believe she favors Major. Aides said she told the cabinet she wanted them to unite behind one of their number -- a clear indication she did not wish to see Heseltine win. In the next round of voting, a simple majority of 187 will suffice for victory. If none of the three achieves that, a third and final round will be held next Thursday.

Heseltine, 57, the former defense secretary and party maverick, can lay claim to the mantle of giant killer after having finished a strong second in the first caucus vote and forcing Thatcher's resignation. Analysts say he must be considered the front-runner because of that showing and because opinion polls indicate he is the candidate most likely to lead the party to victory in the next general election.

A millionaire publisher, Heseltine had stalked Thatcher ever since he resigned from her cabinet in a dispute over Britain's role in Europe in January 1986. He is the most colorful and charismatic of the three contenders, although he has alienated many party loyalists with his single-minded pursuit of power. He is considered more pro-European and more of an economic interventionist than Thatcher, and because he is not a cabinet member he is not saddled with her unpopular fiscal policies -- such as high interest rates and the so-called poll tax system of local assessment.

Hurd and Major can both argue they are better equipped to unite a bitterly split party and heal the deep wounds left by one of the bloodiest intra-party conflicts in modern Tory history. The patrician Hurd, 60, is a professional diplomat who served as home affairs secretary before becoming foreign secretary last year. He is a careful and articulate speaker who has been the government's point man on the gulf crisis. He will attract support from many traditional Conservatives, pro-Europeans and the party's non-Thatcherite left wing.

Major, 47, who comes from a working-class background, is a Thatcher protege who has enjoyed a meteoric rise since entering the cabinet in 1987. He is likely to inherit much of the prime minister's right-wing base and would be expected to carry on her tough economic policies, but he is considered to the left of Thatcher on social issues. Both Major and Hurd are popular within the party but relatively little known by the general public.

"A lot of people are saying that they wished Douglas Hurd and John Major could have gone into a room with a bottle of whiskey and one of them had emerged as the candidate," said Robin Oakley, political editor of the Times of London. "Michael Heseltine has got first run; he's got the momentum going for him; he's got poll evidence that he can actually turn things around for the Tory party. . . . At the moment, he has got a bit more going for him than the other two."

For today, however, many Britons focused more on the prime minister they are about to lose than on the one they are soon to get. Thatcher remained silent as she climbed into her black Daimler and was sped off to Buckingham Palace to submit her resignation to the queen early this afternoon.

But soon afterward, she appeared on the floor of the House of Commons to give a bravura performance, fielding questions from opponents and successfully defending her government in a no-confidence debate called by Kinnock's Labor Party.

Dressed in her familiar bright blue suit, Thatcher appeared relaxed, even lighthearted. Her message to opponents was one of defiant pride, while to her own party members there was the subliminal hint that they would miss her and that perhaps they had been too hasty in jettisoning her.

At one point, after she lost her place in her text following a spirited but not unfriendly exchange with one longtime critic, she smiled broadly and exclaimed: "I'm enjoying this. I'm enjoying this."

"You could wipe the floor with these people," boomed an anonymous voice from the Tory backbenches behind her. And with that, her smile widened.