Prime Minister Margaret Thatcher's dramatic shift in policy toward Zimbabwe-Rhodesia, criticized here by the right wing of her own Conservative Party as a sudden collapse under pressure from black Africa, actually has been evolving for several months.

Thatcher, who knew relatively little about Africa before becoming prime minister in May, was gradually steered by her foreign secretary, Lord Carrington, away from her initial inclination to recognize the biracial government of Prime Minister Abel Muzorewa as quickly as possible.

She seemed to be echoing Carrington's arguments to her in Cabinet committee debate here when she acknowledged at the Commonwealth Conference in Lusaka, Zambia, this week that the world would not recognize the Muzorewa government because its constitution reserves too much power for Rhodesia's white minority and it had little hope of winning the continuing civil war there.

She agreed in Lusaka to hold a conference here in September of all parties in the Rhodesian conflict, to attempt to draft a new constitution under which Britain could grant Rhodesia legal independence with a black majority government approved by the rest of Africa.

"I felt if we went ahead and recognized Rhodesia, we would have been terribly alone," Thatcher said in explaining her change of policy in Lusaka. "In the end, it would not have been very much help to Rhodesia. It would still have left her isolated. It would have left us isolated."

That is exactly what Carrington and Foreign Office diplomats had been telling Thatcher since she became prime minister. Her campaign promise to recognize Muzorewa's government if her observers found that it had been elected fairly, as they later did, had alarmed the Foreign Office, angered black African leaders and helped conservative congressmen in the United States to pressure the Carter administration to end U.S. sanctions against Rhodesia.

Her turnabout in Lusaka diffused a potentially explosive diplomatic problem in black Africa, where Britain has extensive commercial investments and trade. Although it remains to be seen if this latest attempt will succeed in bringing peace to Zimbabwe-Rhodesia, Britain will have tried to negotiate a workable settlement of the racial conflict under its responsibility as the colonial power there.

By taking the initiative, Britain also allows the Carter administration to defer to it and wait to see how Thatcher's plan works before having to make its own decision on whether to continue the economic sanctions.

Thatcher's conversion can be traced to her decision to appoint as her Conservative government's foreign secretary the worldly and well-traveled Peter Alexander Rupert Carrington, the sixth Baron Carrington. An experienced diplomat and cabinet veteran of previous Conservative governments, the 60-year old former opposition leader in the House of Lords agrees with Thatcher on foreign policy goals, especially the need for close British cooperation with a strong Europe and for a strong diplomatic and military defense against the Soviet Union.

On Zimbabwe-Rhodesia, he sought to persuade Thatcher that caution was necessary to protect Britain's interests in southern Africa and the whites remaining in the breakaway British colony. He argued that only black majority rule, recognized as such by the rest of Africa, could produce sufficient stability to protect the white Rhodesians, frustrate Soviet support of the black guerrillas and maintain good relations with important economic partners in black Africa.

Formal speeches and statements by Thatcher and Carrington began to signal a gradual movement from Thatcher's first intention to recognize the Muzorewa government immediately after its election to a search for a form of legal independence for Zimbabwe-Rhodesia that would be internationally acceptable. That search involved consulations among British envoys with black African leaders, Muzorewa and white leaders in Zimbabwe-Rhodesia.

The envoys discovered that Rhodesian whites might agree to some reduction in their reserved powers in the constitution and that neighboring African nations would not object to some legal protections for the white minority, such as reserved seats in Parliment, so long as whites no longer controlled the army, police, courts and civil service and no longer could block laws in Parlimemt.

A small but vociferous group of right-wing Conservative members of Parliment has denounced the Lusaka plan and threatened to demand that Parliment come back into session from its summer recess to it.

Conservative member of Parliment Julian Amery, a long-time defender of the interests of white Rhodesians who led an unsuccessful back-bench revolt against parliamentary renewal of economic sanctions last year, said, "It is pretty obvious that the prime minister and foreign secretary have given into blackmail," by Nigeria, which had threatened economic reprisals if Britain recoginzed Muzorewa's government.

The critics have been outnumbered by other Conservative back-benchers who have praised Thatcher, in the words of member of Parliament Michael Lathan, for having "shown immense diplomatic skill. She went there [to Lusaka] with virtually all the other leaders against her.She will return with a solid and worthwhile agreement achieved largely by the force of her own personality and determination. Not since Disraeli outwitted Bismarck at Berlin in 1878 has a British Conservative prime minister turned such an apparently hopeless negotiating position into such a personal triumph."

Although the right-wing revolt is not expected to cause Thatcher much trouble, not all of Latham's optimism about what was achieved in Lusaka is shared even by Thatcher's government ministers. Many difficult problems remain in the negotiations ahead.

Thatcher and Carrington are to return to London Thursday for a special Cabinet meeting Friday to decide on procedures and a timetable for the proposed constitutional conference here in September. Invitations to the conference may go out as soon as next week, with British envoys again dispatched to southern Africa to try to persuade Muzorewa and leaders of the Patriotic Front guerrillas to attend. "Urgency is the name of the game," one official said today.