The Rev. Leon H. Sullivan yesterday abandoned his code of conduct for companies operating in South Africa and urged the United States to break diplomatic relations and impose a total economic embargo against that country until it ends apartheid.

He asked the 127 companies that follow the Sullivan Principles to withdraw from South Africa within nine months and urged Congress to impose "stringent penalties" on U.S. trading partners who move in to pick up the business. He singled out Japan as an U.S. ally that is "very active in South Africa."

"Every American moral, economic and political force must be brought to bear to help influence the South African government to move toward dismantling the apartheid system before it is too late," Sullivan said in an impassioned announcement that he is abandoning the Sullivan Principles, which are a set of fair-employment guidelines that provide the moral underpinning for U.S. companies operating in South Africa.

He said he was forced into this stance, already espoused by most civil rights leaders, because South Africa's ruling white minority government during the past year has increasingly resisted efforts to improve the conditions of the country's black majority.

Sullivan's announcement is expected to rekindle the debate on the U.S. government's position on South Africa, which settled down last year after Congress overrode President Reagan's veto of a bill imposing economic sanctions on that country for its racial policies.

On Capitol Hill yesterday, reports circulated that new anti-South African provisions, including some pushed by Sullivan, may be included in trade legislation expected to be taken up on the Senate floor later this month.

Before making his public announcement, Sullivan met with representatives of companies that subscribe to the principles to tell them of his new position. While they gave him a standing ovation, they rejected his call that they pull out of South Africa.

"We will now have to carry out the Sullivan Principles without Sullivan," said Allan Murray, chief executive officer of Mobil Corp. and one of three cochairman of the U.S. Corporate Council on South Africa.

But Sullivan said he is wielding the club of $80 billion to $90 billion in investment funds that will be used against companies that continue to do business in South Africa. These funds -- controlled by pension funds, universities, labor unions and public institutions -- will be taken away from companies that continue to operate in South Africa or will be used to force stockholder resolutions at annual meetings.

The Reagan administration also rejected Sullivan's plea for disinvestment. "Despite the difficulties on the ground in South Africa, we firmly believe that it is now more important than ever for U.S. firms to stay and work for an end to apartheid," said State Department spokesman Charles Redman.

But private groups working against apartheid praised Sullivan's decision.

"I think he has removed the last crutch on which the corporate community has depended for justification for its presence in South Africa. I think it will accelerate the rate of corporate departure and, as a consequence, increase pressure on South Africa to begin a process of meaningful negotiations," Randall Robinson of TransAfrica said.

Sullivan, though, applauded the 10-year history of the Sullivan Principles for their "notable record of corporate social responsibility in South Africa." He said they "have caused a revolution in industrial race relations in South Africa and have broken new ground for black worker rights in South Africa that had not existed for 300 years."

Nearly 200 U.S. firms operate in South Africa. But more than 100 major U.S. companies have left South Africa during the last 18 months under strong pressure from group's such as TransAfrica.

Sullivan, the 64-year-old pastor of Zion Baptist Church in Philadelphia, said that he anguished over his decision because he was concerned that black workers would suffer if more U.S. companies withdrew from South Africa. But, he concluded, blacks would be better off in the long run as the result of strong action today against apartheid. Sullivan called apartheid the greatest moral issue facing the world today.

"South Africa has become a nation of suppression and a police state," he said. "What is happening to black people in South Africa is immoral and wrong, and must be brought to an end."

He told a crowded news conference that "the winds of change have reached South Africa, and will not be subdued until the black people have full economic, social and polital freedom.

"Violently or nonviolently, the people are going to have it," he said. The alternative to a quick start toward peaceful change, he said, is "a chaotic revolution with the killing of millions of people, the destruction of a country, the devastation of the entire southern region of Africa" that could lead to a superpower confrontation.

He warned, moreover, that "race riots will break out in every major city of this country that are far worse than anything we have seen in the history of America" if the United States sides with the South African government in a confrontation with the country's black population.