NEC Corp., Japan's leading computer maker, said Monday it will spend about $40 million to increase the use of foreign-made semiconductors by July 1991 when a U.S.-Japan semiconductor agreement expires.

NEC officials said the company decided to raise its share of foreign-made chips to about 24 percent of the total at the request of the Ministry of International Trade and Industry. Currently, about 20 percent of the chips it uses are imported.NEC is reported to have been buying semiconductors worth about $1.3 billion a year from outside the company, with foreign-made chips accounting for about $267 million of that total.

At the same time, Japan's Ministry of International Trade and Industry said Monday that the share of foreign-made computer chips in the Japanese market rose for the fourth consecutive quarter to hit a record 12.9 percent during the three-month period ending Dec. 31.

''The figure reflects the fact that Japanese companies' continued efforts to expand their imports of foreign chips are producing results," a MITI official said.

Industry sources said other Japanese chip users may follow NEC's lead and boost foreign chip purchases to cushion U.S. complaints that the market share for foreign-made semiconductors in Japan has not reached the 20 percent level agreed upon four years ago.

Japan pledged in the 1986 pact with the United States to avoid microchip dumping, or selling below cost, overseas and to open the market for foreign microchips.

In a separate letter attached to the agreement, Japan also acknowledged that the U.S. industry wants to achieve a 20 percent share of the Japanese market before the pact expires.

NEC's decision comes on the heels of the weekend meeting between Japanese Prime Minister Toshiki Kaifu and President Bush, where the two discussed trade matters and agreed to continue efforts toward breaking down trade barriers. According to Japanese newspaper reports, the semiconductor issue was raised. (Related story, Page 3A.)

MITI is expecting the new statistics to serve as good material with which to impress Congress and the semiconductor industry.

The share of foreign chips in the Japanese market has been steadily increasing since the Japan-U.S. chip pact was signed, when it was 8.6 percent. The value of Japan's chip imports rose 2.3-fold last year. Most of the imported semiconductors are believed to have come from U.S. makers.

MITI has been trying to persuade major Japanese chip users such as home electric appliance makers and automakers to use more imported chips.

The ministry also has been encouraging joint chip development projects in which U.S. makers are involved from the design phase.

In the same vein, the Japanese and U.S. chip industries agreed last November to develop special chips for high-definition televisions that offer images of motion-picture quality.

Meanwhile, Japan's semiconductor manufacturers are steadily consolidating their dominance in the memory chip market.

For example, the country's semiconductor makers believe they are moving ahead of their U.S. and European rivals in the race to develop advanced technology known to be crucial in producing next-generation chips boasting more than 100 megabits of memory.

The Japanese industry has already launched mass output of 4-megabit dynamic random access memories, or Drams, and some makers, including International Business Machines Corp., Texas Instruments Inc., Toshiba Corp. and Hitachi Ltd., are believed to be close to commercial production of 16- megabit chips.

Now, however, research and development activities are shifting to 64-megabit memory chips. These can carry four times more information than a 16-megabit chip and can store the equivalent of around 6,400 pages of double- spaced typewritten copy.

Chip specialists in Tokyo report that the industry even now is heading toward a process in which a billion transistors can be jammed into a stamp-size chip.