Prime Minister Brian Mulroney and British Prime Minister Margaret Thatcher found themselves at loggerheads today after the Canadian leader tried and failed to persuade Thatcher to agree to join the other Commonwealth nations in imposing economic sanctions against South Africa.

In forceful comments to reporters after the British leader had left following a weekend visit to Canada, Mulroney referred to the South African government as an "evil regime" and called his talks with Thatcher about South Africa comprehensive and "very frank."

He also said that all 49 Commonwealth nations, including by pointed implication, Britain, had already committed themselves to such curbs and that Canada was prepared to act alone on the issue if necessary.

But Thatcher, clearly acting to deflect mounting pressures on her before a special Commonwealth meeting in London next month to consider the issue of sanctions, said in interviews last week before coming to Canada that she thought sanctions would be "immoral" and "utterly repugnant."

After meeting with Mulroney for 90 minutes today, she declared that her position had not changed.

"The question is how best to get rid of apartheid in South Africa," she said. "I would suggest it is by negotiation. I can't see any other way of doing it."

Mulroney and Thatcher met at a hotel across from the international airport here today during a refueling stopover as Thatcher returned to London from a visit to the world's fair, Expo '86, in Vancouver. After introducing Thatcher to the press, Mulroney left the room, allowing her to answer reporters' questions alone.

Once her plane was airborne, Mulroney returned and stated his differences with her diplomatically but firmly.

The Canadian prime minister, waving a finger for emphasis, spoke with strong emotion. "It's all about dealing with a regime that is rooted in evil, when an entire generation of people have been suppressed, deprived of their fundamental rights, their liberty and dignity as human beings.

It's a regime constructed on the concept that people are fundamentally unequal. It is unacceptable to civilized governments and civilized societies.

It ought to be unacceptable to all of us of the Commonwealth and all prime ministers."

Canadian newspapers and leaders of other Commonwealth countries had held out hope that Mulroney might be able to change Thatcher's mind and avoid threatened protests by Commonwealth members against Britain's stance and a major rift within the organization.

Tanzania Sunday became the fifth black African country to announce it will boycott the Commonwealth Games in Scotland beginning July 24 to protest British policy. It joined Nigeria, Ghana, Uganda and Kenya, Reuter reported.

In Edinburgh, the Commonwealth Games Federation banned South African-born athletes Zola Budd and Annette Cowley from taking part.

Zambian President Kenneth Kaunda, who has threatened to leave the Commonwealth over the issue of sanctions, told the Toronto Globe and Mail newspaper's Africa correspondent last week, "Let Britan do anything possible to tell that Iron Lady she should not isolate herself in the Commonwealth. . . . If there's one person who can succeed within the Commonwealth, it's Brian."

Thatcher seemed perturbed at the notion that Mulroney, acting as mediator, might change her mind. "We don't need a mediator between Commonwealth leaders," she said yesterday. "We get together and we discuss."

The meeting today foreshadowed a gathering of seven Commonwealth leaders Aug. 3-5 in London, where consideration is to be given to a report by the so-called "Eminent Persons Group" created during the meeting last October in Nassau to examine the situation in South Africa.

Under accords reached in Nassau, Commonwealth countries also pledged to ban air links to South Africa, new investment, promotion of tourism and to terminate double taxation agreements unless steps had been taken by now to begin dismantling the system of apartheid.

Thatcher had initially balked at such commitments but went along grudgingly after a series of private sessions with Mulroney and Indian Prime Minister Rajiv Gandhi.

Britain is the largest foreign investor in South Africa.

Today, Thatcher sharply rebuked a reporter who suggested that the report by the Eminent Persons Group, issued last month and predictint a bloodbath of major proportions in South Africa unless western nations act, had called for sanctions.

Later, Mulroney said that if you read the report quite literally "you can put any construction on it you want." But, he said, the "spirit" of the recommendations was clearly in favor of Commonwealth nations acting in concert to take economic measures against South Africa.

In the interviews last week with British and Canadian newspapers and broadcast organizations in London, Thatcher said black South Africans such as Bishop Desmond Tutu could call for sanctions because they had good jobs and did not have to worry about taking care of their children.

The vast majority of nonwhites in South Africa would be thrown out of work, she argued.