From Maritime Ryukyu, 1050–1650, by Gregory Smits (University of Hawaii Press, 2018), Kindle pp. 84-88:
A crucial context for the development of Ryukyu was the warfare between Japan’s Northern and Southern Courts, especially in Kyushu. Wakō attacks on the Korean coast intensified in 1350 and continued for decades. Attacks occurred on a large scale, sometimes involving hundreds of ships and thousands of combatants. The most intense period of wakō marauding was from 1375 to 1388. Some scholars point to lack of agricultural productivity in the classic wakō havens as a major reason for these depredations. Paddy land, for example, comprised only 3 percent of Tsushima. Similarly, poverty was also a severe problem in Kyushu at this time. Given the massive scale of wakō attacks, however, another impetus was the need for grain to supply Southern Court armies. Prince Kaneyoshi, the court’s leader in Kyushu, actively collaborated with wakō toward this end. In other words, wakō based near the coast of Higo [Kumamoto area] and at Tsushima, Iki, and Matsuura supported Prince Kaneyoshi and his Southern Court by providing needed supplies, plundered from Korea. In return, Kaneyoshi provided protection for the wakō. In contrast, Kyūshū tandai Imagawa Ryōshun, head of the Northern Court in Kyushu, sought to suppress wakō piracy.
Envoys from Korea traveled to Japan in an effort to stem the tide of piracy, the first of whom arrived at Kyoto in 1366. The Muromachi bakufu sought good relations with Korea, but its control over Kyushu was limited at the time. The piracy problem prompted the bakufu to pursue military pacification of Kyushu. It eventually succeeded, but the Southern Court wakō became even more active during the 1370s, prompting the following 1375 message from the bakufu to the Korean court via the Tenryūji priest Tokusō Shūsa: “Kyushu is broken apart by rebelling subjects and does not pay tribute; the stubborn subjects of the Western seacoast have become pirates. But these are not the doing of the bakufu. We are planning to dispatch a general to Kyushu to pacify the area and can promise to suppress the pirates.” Success in carrying out this promise required more than fifteen years. Southern Court wakō also attacked China, albeit less frequently. While the Korean court had obvious reasons to be gravely concerned with putting a stop to the wakō attacks, the reasons for the similarly intense concern by the Hóngwǔ emperor require further explanation. ...
It is possible that the Korean court misunderstood the contours of political power in Japan at the time, especially the Seiseifu–wakō connection. By contrast, the Ming court dealt directly with Prince Kaneyoshi, attempting to make him into king of Japan. Some scholars have taken this move as a sign that Ming officials did not understand Japan’s internal conditions. However, it is more likely that the Ming court knew exactly who controlled the wakō and thus initially focused on Kaneyoshi.
The basic timeline of the rise and fall of the Southern Court in Kyushu begins in 1348 with a castle on the Higo coast near Yatsushiro that had two names, Hanaoka castle or Sashiki castle. It was in the territory of the Nawa family, who provided naval forces for the Southern Court. Seiseifu [征西府 'subjugation of the west'] headquarters moved around Kyushu with the changing tides of war. Seiseifu occupied the same space as the old Dazaifu between 1360 and 1372, the peak of Southern Court power. It relocated to Kikuchi in the mountains of Higo until 1381. ... The Southern Court reunited with the Northern Court in 1392 ....
The defeat of the Southern Court in Kyushu caused migrations of wakō into the Ryukyu islands. ... The collapse of Seiseifu power during the 1380s and 1390s put pressure on the Southern Court wakō in Kyushu to migrate. Moreover, developments in Korea also pressured wakō bands to change their tactics. Analysis of the number and size of wakō attacks compared with what they obtained and the losses they incurred reveals that even during the period 1364–1374, they had begun to experience diminishing returns to scale. The trend continued. The number and size of attacks increased during the 1370s and 1380s, but Korean resistance and evasion resulted in fewer per capita gains. For the most part, the effectiveness of wakō marauding in Korea tracked the rise and decline of Seiseifu. One result of decreasing wakō gains in Korea was an increase in raids on the Chinese coast. An element in this complex mix was increasingly effective Korean defenses, including costal fortifications, coordinated signal beacons using fire, more and better ships, better commanders, and more soldiers along the coast. The founding of the Joseon (Yi) dynasty in 1392 accelerated this process.
By the 1390s Southern Court wakō lost their state sponsors and many of their bases. They could still operate from islands such as Tsushima, but a hostile Muromachi bakufu, improved Korean defenses, and lower demand for the possible spoils of their attacks on Korea had the effect of pushing wakō bands southward. By this time, the busiest harbor in the Ryukyu islands was Naha.
...
The port of Naha served as a major intersection within the East China Sea network through which “pirates, captives, fishermen, divers, envoys, monks, traders, and other people traveled” during the fourteenth through sixteenth centuries. Merchants or wakō in Japan would have found sailing to Naha for trade more practical or more profitable than journeying directly to the coast of China or farther afield. The result was the creation of “a strange relationship of dependency” between Ryukyuan and Japanese merchants.
The first appearance of Ryukyu as a state in Korean records begins with a 1389 statement that an embassy from Ryukyu returned Koreans who had been captured by pirates. The repatriation of captured Koreans recurred frequently thereafter as a reason for Ryukyu-sponsored voyages to Korea. Although the Korean court granted favorable treatment to these embassies, it did not actively encourage trade with Ryukyu. In this context, Korean people were valuable commodities, whose repatriation permitted potentially lucrative trade embassies. Repatriation was not necessarily an act of benevolence. It constituted “one variety of the slave trade.”