Japanese Prime Minister Yasuhiro Nakasone will visit Seoul early next week for talks with South Korean President Chun Doo Hwan in a bid to ease strained relations between the two countries by offering the Chun government a $4 billion package of economic aid, Foreign Ministry officials said today.

The surprise move was widely interpreted by observers in Tokyo and Seoul as a statesmanlike gesture on Nakasone's part, designed to end 18 months of often stormy negotiations. South Korea has been demanding that Japan, its wealthy Asian neighbor, boost substantially its help in financing Seoul's ambitious economic development projects. An early settlement of the hotly debated issue is regarded here as important because it may open the way for improved ties between America's two key allies in Northeast Asia.

In announcing that Nakasone would travel to Seoul for talks with Chun next Tuesday and Wednesday, Chief Cabinet Secretary Masaharu Gotoda told reporters today that the two leaders would "exchange views on international affairs" and discuss ways to improve "the cooperative relationship" between the two countries. Both sides, he said, had agreed to approach the long deadlocked aid issue "in the spirit of mutual concession." Nakasone's scheduled visit will mark his first trip to a foreign capital since he became prime minister on Nov. 26.

Talks between Tokyo and Seoul hit an impasse almost immediately after the South Korean government made its initial request in August 1981 for $6 billion in low-interest loans for economic development during the five years ending in 1986. The issue was one of the thorniest ones confronting the administration of Nakasone's predecessor, Zenko Suzuki. According to knowledgeable Japanese officials, a compromise agreement was reached early last year to reduce the overall amount to a total of $4 billion. But the two sides remained far apart on the conditions and interest rates of the loans.

According to reports in the Japanese press, Japan's offer provides for the equivalent of $1.85 billion in government-sponsored, concessionary yen credits from Tokyo's overseas economic cooperation fund. The remaining $2.15 billion, the reports said, will be extended by Japan's export-import bank and tied to the purchase of Japanese goods. The yen credits and export-import funds were expected to carry yearly interest charges of roughly 4 percent and 6 percent, respectively.

Foreign Ministry officials today confirmed the broad outlines of the funding package, which they said represented Tokyo's largest aid package since its foreign assistance program began. They declined to outline the details, however, pending a final agreement between the two governments, which they expect to come next week. Akitane Kiuchi, director general of the ministry's Asian affairs bureau, flew to Seoul today in an apparent bid to smooth the way for Nakasone's visit.

News of Nakasone's decision to visit Seoul to settle the issue personally was greeted by surprise in the South Korean capital, where evening newspapers predicted that it would help usher in a "new era" in friendly ties between the two countries. Special importance was attached to the fact that the trip comes in advance of Nakasone's scheduled visit to Washington later this month for talks with President Reagan.

Since Nakasone came to office in November, he has stressed the need to strengthen relations with the United States, which have been badly strained by the issues of trade and defense. His low profile on relations with key Asian countries has, at the same time, churned up charges in the region that he was shirking Japan's responsibilities to developing countries there.

Efforts to reopen the long-stalled aid talks with South Korea, Chief Cabinet Secretary Gotoda said today, had been quietly undertaken through diplomatic channels shortly after Nakasone was named prime minister. Relations between the two countries have been particularly fragile since the abduction of South Korean political dissident Kim Dae Jung from a Tokyo hotel room in 1973, allegedly by agents of former president Park Chung Hee's government in Seoul.

They took on a deep chill last July when Japanese school authorities' move to revise textbook accounts of World War II touched off a sense of outrage among the South Korean public. Koreans objected to "distortions" in the textbooks, which they said deleted unsavory facts pertaining to Japan's 50 years of colonial rule of Korea that ended in 1945.

The release of Kim Dae Jung by the Seoul government to virtual political exile in the United States in late December and the earlier diplomatic settlement of the textbook issue, senior Japanese officials said, helped open the way for Nakasone's visit to Seoul, making possible an early solution to the aid dispute. Official Japanese development assistance to South Korea, which amounted to $83 million in 1980, has been frozen for the past two years.

In early negotiations, Seoul officials had argued that the magnitude of their aid request was justified because South Korea's heavy burden of military spending was, in effect, helping to underwrite the defense of Japan and entitled the country to nonmilitary compensation in the form of economic aid. South Korea now spends roughly 6 percent of its $60 billion gross national product on defense, while Japan, whose GNP is 20 times larger, spends slightly less than 1 percent.

Seoul subsequently stepped back from using the concept of military burden-sharing as a bargaining chip and South Korean officials stressed that the loans would be earmarked for the construction of schools, hospitals, subway lines, dams and other purely economic projects under the government's current five-year development program.

According to reports in the Japanese press, Reagan administration officials welcomed news of Nakasone's visit to Seoul next week as a move which would contribute to peace and stability in Asia by helping to ease tensions between Japan and South Korea. Nakasone's trip comes in advance of a scheduled visit by Secretary of State George P. Shultz to the two countries beginning in late January.