The government of Prime Minister Yasuhiro Nakasone today approved the transfer of military technology to the United States in a move signaling a major shift in Japan's 15-year-old ban on the export of weapons.

In an official announcement this morning, Masaharu Gotoda, the chief Cabinet secretary, said the Nakasone government had decided, in principle, to supply the United States with sophisticated military know-how to put defense ties between the two countries on a more equal footing.

The issue has been sharply debated among government departments here since U.S. officials 18 months ago strongly urged Tokyo to open the way for the full-scale flow of Japan's increasingly important electronics and other high-technology know-how into Pentagon weapons development projects.

Today's decision came only four days before Nakasone was scheduled to leave for talks in Washington with President Reagan, during which he hopes to impress upon the American president Japan's determination to enlarge its role in the military sphere.

Gotoda said the change in Tokyo's longstanding weapons export policy was "extremely important to ensure the effective operation" of the 32-year-old security treaty between Japan and the United States. Under the security pact, the flow of weapons technology has been overwhelmingly in Japan's favor.

Citing the rapid advances in Japanese technological might in recent years, Gotoda said the time had come to make the technological exchange more reciprocal.

According to knowledgeable sources here, the move was intended as a sweetener for Nakasone's summit talks with Reagan, which are expected to dwell on relations badly strained over the thorny issues of trade and defense. It follows Tokyo's recent decision to increase its defense spending in 1983 by 6.5 percent, a figure that considerably undershot the expectations of Reagan administration officials.

Nakasone, who came to office Nov. 26, ordered key Cabinet officers last month to hammer out an early settlement in the issue as part of a bid to improve ties with the United States.

Progress had been deadlocked because of the strong opposition of the Ministry of International Trade and Industry, the watchdog of the country's big business interests. MITI officials argued that any agreement to free the flow of highly classified advanced industrial technology would damage Japan's commercial position.

U.S. officials have asserted that they have no "shopping list" for Japanese military know-how in mind, but they are believed to be interested in advanced electronics, fiber optics, laser technologies and sophisticated composite materials used in the production of jet engines and military aircraft.

Government sources said today the decision was likely to churn up "enormous opposition" among opposition parties in parliament and pacifist elements in the Japanese public, who charge that Nakasone's conservative Liberal Democratic Party is trying to abandon the country's arms export prohibitions.

In his remarks today, Gotoda said that the decision would not lead to substantial additional changes in Japan's longstanding weapons export ban. He said the transfer of military technology to the United States will be carried out under the framework of U.S.-Japanese security arrangements and, therefore, would remain an exception to broader weapons-related policies.

Since 1967, Tokyo banned arms exports to communist countries, countries falling under the United Nations' weapons ban and countries involved in international conflicts.