Margaret Thatcher, the Conservative Party leader who has electrified British politics by introducing race as an issue, is having some second thoughts.

Despite polls showing that her call to end immigration has sharply boosted Conservative stock, she is beginning to discover that the tricky issue cuts two ways.

Thatcher is learning that she runs the risk of arousing hitherto politically dormant black and brown voters, turning them into a militant bloc supporting the Labor Party. She is also dismaying the liberal wing of her own party and has been openly rebuked by Edward Heath, the former prime minister.

Now she faces a testing time of careful calculation. She must weigh her potential losses against the clear inroads she is making in Labor's strength by appealing to workers' fear for their jobs and the distate of some who live alongside nonwhite people.

The first, crude poll results after Thatcher issued her call turned up striking gains. In the National Opinion Poll, Thatcher turned a 44-46 deficit competing with Labor into a stunning 50-39 advantage. Gallup was almost as good, with Tories going from a 43.5-53.5 dead heat to a 48-39 edge.

The Daily Mail, one of the more strident Tory papers, crowed in a page one headline, "Maggie's Got It Right."

The only doubt was that Labor still maintained an advantage as the party voters thought was best equipped to deal with the key economiv issues. Yesterday's announcement, that inflation has finally fallen below 10 percent, should help the government too.

It was The Daily Telegraph, a more sober Tory paper, that warned Thatcher in a headline: "Next Election May Turn On Colored Vote." The paper discovered that immigrants hold the balance of power in 59 of the 635 parliamentary districts, including 9 marginal Labor seats that Thatcher hungers for.

Indeed, the National Opinion Poll that so cheered the Daily Mail carried much the same warning. It showed that West Indians now prefered Labor by a cruching 92-5 percent margin and the Asians by 86-8.

Up to now, the immigrants have not mustered their strength. Their turnout at election is low and they have no political organizations of weight. There is not even a British equavalent of the Urban League let alone a National Association for the Advancement of Colored People.

The parties have generally neglected immigrants too, despite the fact that they number about 1.8 million or more than 3 percent of the population. The Tories have in the past tried to recruit Asian shopkeepers but those days are now over.

Earlier this week, Heath, who was ousted as Conservative leader by Thatcher, declared flatly and coldly that her issue had raised "an unnecessory national row." He came as close as he could to saying that Thatcher had stirred an empty pot.

She then began pulling back. Talking to the Young Conservatives, she dropped her previous demand to limit immigrants dependents allowed to enter the country to wives and young children. She reaffirmed the pledge to admit ultimately all the Asians with British passports who are being driven from Kenya. She repeated another pledge to uphold the amnesty that allowed immigrants entering illegally to stay.

Above all, she repeated the formula of a Heath man, William Whitelaw, the deputy leader. He speaks not of ending immigration but of working toward ending the postwar pace of admissions.

Even so, Prime Minister James Callaghan and the Labor Party are running scared. As one key official put it, "She is going for out people. The working class man feels endangered by colored people taking his job away."

Callaghan's first response was a ploy. He challenged Thatcher to take the delicate issue out of politics and join all-party talks on immigration. She ducked that one nimbly.

Callaghan's next response has been to show he can't be outflanked on race. He has had his home secretary, Merlyn Rees, advertise how tough Labor has been in deporting illegal immigrants and adopt almost word for word the Whitelaw formula on reducing the postwar rate of admissions.

Thatcher's gamble may yet pay off, but neither she nor any other politician here has a clear idea of all the ways it can cut.