TOKYO, JAN. 25 -- Japan has become South Africa's leading trading partner despite its official opposition to apartheid, a rank that has the Japanese government "very much worried and embarrassed," a senior official said today.

Japan's trade with South Africa grew from $3.6 billion in 1986 to $4.3 billion last year, according to Japanese statistics. While Japan and the United States led the world with nearly equal trade with South Africa in 1986, last year's figures put Japan clearly in the lead.

"We can safely say that in 1987 the figure of our trade is by far bigger than any other country's," a Foreign Ministry official said. "These are the facts. This certainly embarrasses the government."

Japan officially opposes South Africa's apartheid system, under which a white minority rules the nation's blacks who are rigidly segregated and not permitted to vote.

But officials here worry that growing commercial traffic with the nation will undermine Japan's opposition to apartheid and further alienate many Americans who already believe Japan puts commercial interests above principle.

The Foreign Ministry official, who asked not to be named, said that much of the government, including the prime minister and ruling party, is too closely linked to big business to favor economic sanctions or other actions that might severely harm industry.

The official also said Japan's public is not sufficiently alarmed by apartheid to press for greater economic sanctions, a condition the Foreign Ministry is hoping to correct in part by helping informally to publicize "Cry Freedom," the recently released movie about anti-apartheid fighters Stephen Biko and Donald Woods.

"When it comes to the moral responsibility or consciousness, I would say that even today the Japanese people are quite weak," the official said.

The Japanese government is divided about the need for further action, however. While Foreign Ministry officials would like to restrict trade further with South Africa, officials in the Ministry of Trade and Industry (MITI), which works more closely with Japanese companies, are less dismayed by the figures and see no pressing need for change.

"The logical thing is to take action to push reform in the apartheid system; it isn't logical to take action simply because Japan is number one in the trade figures," said a senior MITI official, who also asked not to be identified. "For the moment, just because Japan is number one, we are not thinking in our ministry of taking any measures to strengthen sanctions."

Officials in both ministries pointed out that most of the increase in Japan-South Africa trade last year can be attributed to exchange rate changes. In yen terms, trade increased by only 2.1 percent, from 607 billion to 620 billion, which, in turn, was lower than the 1985 figure of 687 billion or the even higher figure in 1984 of 816 billion.

Japanese officials also noted that in many noneconomic areas and even some areas related to trade, they take a harder line against South Africa than most western nations. Japan prohibited direct investment in South Africa long before the United States began considering such restrictions, and it strictly limits sports and cultural exchanges, tourism and the export of computers to law enforcement agencies.

One official questioned why Japan should be singled out for criticism when other countries, such as West Germany, have fewer restrictions and also have increased bilateral trade.

Nonetheless, a Foreign Ministry official said Japan's emergence as the number one trading partner could lead South Africa to believe that Tokyo is unconcerned about apartheid.

"I personally think that our government should have intensive discussions with business circles," the official said. "But it is principally MITI that has the mandate to do so."

The official said it is often difficult for the Japanese government, which has been headed by the conservative Liberal Democratic Party for more than three decades, to move against business interests. Referring to Japan's most powerful industry association, the official added, "The president of the Keidanren is more powerful than the prime minister sometimes."

Japan's exports cars, machinery and electronics equipment to South Africa. It imports mostly raw materials, notably coal and gold, platinum and other metals.

South Africa accounts for only about one percent of Japan's world trade, but half its trade with Africa.

Officials in both ministries said there is no evidence that Japanese companies have tried to fill gaps left by U.S. firms that have pulled out. The MITI official said imports from South Africa actually declined 7.4 percent in yen terms last year, while a 17 percent increase in exports was caused by an improvement in the South African economy.

They said that while Japanese computer companies, especially Hitachi, sell to South Africa through West Germany, their market share remains small compared to IBM's.

On the other hand, they acknowledged that such sales through third parties makes Japan's trade with South Africa look smaller in statistics than it really is.

Any evidence that Japanese companies had taken advantage of U.S. firms' withdrawal could be explosive in Washington, where officials already are angry about Japan's trade surplus with the United States and last year's case involving sales of militarily useful technology to the Soviet Union by Japan's Toshiba Machinery Co.

"The difficult thing about this issue is that there's no violation at all, but still something is wrong and criticism will be raised," a Foreign Ministry official said.

The South African trade could particularly anger black politicians, many of whom first complained about the issue after prime minister Yasuhiro Nakasone made a derogatory comment about blacks and Hispanics dragging down the U.S. educational level.

A Foreign Ministry official said he believes that Japanese should feel a special obligation to help end apartheid, since Asians as well as blacks have been the object of discrimination in South Africa.