The Haijin or sea ban was a series of related isolationist Chinese policies restricting private maritime trading and coastal settlement during most of the Ming dynasty and some of the Qing. First imposed to deal with Japanese piracy amid the mopping up of Yuan partisans, the sea ban was completely counterproductive: by the 16th century, piracy and smuggling were endemic and mostly consisted of Chinese who had been dispossessed by the policy. China's foreign trade was limited to irregular and expensive tribute missions, and resistance even to them among the Chinese bureaucracy led to the scrapping of Zheng He's fleets. Piracy dropped to negligible levels only upon the end of the policy in 1567, but a modified form was subsequently adopted by the Qing. This produced the Canton system of the Thirteen Factories, but also the opium smuggling that led to disastrous wars with Britain and other European powers in the 19th century.
The 14th century was a time of chaos throughout East Asia. The second bubonic plague pandemic began in Mongolia around 1330 and may have killed the majority of the population in Hebei and Shanxi and millions elsewhere. Another epidemic raged for three years from 1351–1354. Existing revolts over the government salt monopoly and severe floods along the Yellow River provoked the Red Turban Rebellion. The declaration of the Ming in 1368 did not end its wars with Mongol remnants under Toghon Temür in the north and under the Prince of Liang in the south. King Gongmin of Korea had begun freeing himself from the Mongols as well, retaking his country's northern provinces, when a Red Turban invasion devastated the areas and laid waste to Pyongyang. In Japan, Emperor Daigo II's Kenmu Restoration succeeded in overthrowing the Kamakura shogunate but ultimately simply replaced them with the weaker Ashikaga.
The loose control over Japan's periphery led to pirates setting up bases on the realm's outlying islands, particularly Tsushima, Iki, and the Gotōs. These "dwarf pirates" raided Japan as well as Korea and China.
As a rebel leader, Zhu Yuanzhang promoted foreign trade as a source of revenue. As the Hongwu Emperor, first of the Ming Dynasty, however, he issued the first sea ban in 1371. All foreign trade was to be conducted by official tribute missions, handled by representatives of the Ming Empire and its "vassal" states. Private foreign trade was made punishable by death, with the offender's family and neighbors exiled from their homes. A few years later, in 1384, the Maritime Trade Intendancies (Shibo Tiju Si) at Ningbo, Guangzhou, and Quanzhou were shuttered. Ships, docks, and shipyards were destroyed and ports sabotaged with rocks and pine stakes. Although the policy is now associated with imperial China generally, it was then at odds with Chinese tradition, which had pursued foreign trade as a source of revenue and become particularly important under the Tang, Song, and Yuan. A 1613 edict prohibited maritime trade between the lands north and south of the Yangtze River, attempting to put a stop to captains claiming to be heading to Jiangsu and then diverting to Japan.
Although the policy has generally been ascribed to national defense against the pirates, it was so obviously counterproductive and yet carried on for so long that other explanations have been offered. The initial conception seems to have been to use the Japanese need for Chinese goods to force them to terms. Parallels with Song and Yuan measures restricting outflows of bullion have led some to argue that it was intended to support the Hongwu Emperor's printing of fiat currency, whose use was continued by his successors as late as 1450. (By 1425, rampant counterfeiting and hyperinflation meant people were already trading at about 0.014% of their original value.) Others assert that it was a side effect of a desire to elevate Confucian humaneness (仁, ren) and eliminate greed from the realm's foreign relations or a ploy to weaken the realm's southern subjects to the benefit of the central government. Nonetheless, it may have been the case that the Hongwu Emperor prioritized protecting his state against the Northern Yuan remnants, leaving the policy and its local enforcers as the most he could accomplish and his mention of them in his Ancestral Injunctions as responsible for their continuation.
The policy offered too little—decennial tribute missions comprising only two ships—as a reward for good behavior and enticement for Japanese authorities to root out their smugglers and pirates. The Hongwu Emperor's message to the Japanese that his army would "capture and exterminate your bandits, head straight for your country, and put your king in bonds" received the Ashikaga shogun's cheeky reply that "your great empire may be able to invade Japan but our small state is not short of a strategy to defend ourselves".
Although the sea ban left the Ming army free to extirpate the remaining Yuan loyalists and secure China's borders, it tied up local resources. 74 coastal garrisons were established from Guangzhou in Guangdong to Shangdong; under the Yongle Emperor, these outposts were notionally manned by 110,000 subjects. The loss of income from taxes on trade contributed to chronic funding difficulties throughout the Ming, particularly for Zhejiang and Fujian provinces. By impoverishing and provoking both coastal Chinese and Japanese against the regime, it increased the problem it was purporting to solve. The initial wave of Japanese pirates had been independently dealt with by Jeong Mong-ju and Imagawa Sadayo, who returned their booty and slaves to Korea; Ashikaga Yoshimitsu delivered 20 more to China in 1405, which boiled them alive in a cauldron in Ningbo. However, the raids on China continued, most grievously under the Jiajing Emperor. By the 16th century, the "Japanese", "dwarf", and "eastern barbarian" pirates of the Jiajing wokou raids were mostly non-Japanese.
Nonetheless, because the sea ban was added by the Hongwu Emperor to his Ancestral Injunctions, it continued to be broadly enforced through most of the rest of his dynasty. For the next two centuries, the rich farmland of the south and the military theaters of the north were linked almost solely by the Jinghang Canal. Bribery and disinterest occasionally permitted more leeway, as when the Portuguese began trading at Guangzhou (1517), Ningpo ("Liampo"), and Quanzhou ("Chincheu"), but crackdowns also occurred, as with the expulsion of the Portuguese in the 1520s, on the islands off Ningbo and Zhangzhou in 1547, or at Yuegang in 1549. The Portuguese were permitted to settle at Macao in 1557, but only after several years of helping the Chinese suppress piracy.
Piracy dropped to negligible levels only after the general abolition of the policy in 1567 upon the ascension of the Longqing Emperor and at the urging of the governor of Fujian. Chinese merchants were then permitted to engage in all foreign trade except with Japan or involving weapons or other contraband goods; these included iron, sulfur, and copper. The number of foreign traders was capped by a license and quota system; no trading could take them away from China for longer than a year. Maritime trade intendancies were reëstablished at Guangzhou and Ningbo in 1599, and Chinese merchants turned Yuegang (modern Haicheng, Fujian) into a thriving port. The end of the sea ban did not mark an imperial change of heart, however, so much as a recognition that the weakness of the later Ming state made it impossible to continue the prohibition. The state continued to regulate trade as heavily as it could, and foreigners were restricted to doing business through approved agents, with prohibitions against any direct business with ordinary Chinese. Accommodations could be made, but were slow in coming: the merchants of Yuegang were trading heavily with the Spanish within a year of Maynila's 1570 conquest by Martín de Goiti but it wasn't until 1589 that the throne approved the city's requests for more merchant licenses to expand the trade. Fu Yuanchu's 1639 memorial to the throne made the case that trade between Fujian and Dutch Taiwan had made the ban entirely unworkable.
As the Qing expanded south following their victory at Shanhai Pass, the Southern Ming were supported by the Zheng clan. Zheng Zhilong surrendered the passes through Zhejiang in exchange for a wealthy retirement, but his son Zheng Chenggong—better known by his Hokkien honorific Koxinga—continued to resist from Xiamen and then, after wresting its control from the Dutch, Taiwan. His dynasty then developed it as the independent state of Tungning, but were driven from their mainland bases in 1661.
The Qing regent Prince Rui resumed the sea ban in 1647, but it was not effective until a more severe order followed in 1661 upon the ascension of the Kangxi Emperor. In an evacuation known as the "Great Clearance" or "Frontier Shift", coastal residents of Guangdong, Fujian, Zhejiang, Jiangsu, and parts of Shandong were required to destroy their property and move inland 30–50 li (about 16–26 km or 10–16 mi), with Qing soldiers erecting boundary markers and enforcing the death penalty on those beyond it. Ships were destroyed, and foreign trade was again limited to that passing through Macao. Checks and adjustments were made the following year, and the inhabitants of five counties—Panyu, Shunde, Xinhui, Dongguan, and Zhongshan—moved again the year after that. Following numerous high-level memorials, the evacuation was no longer enforced after 1669. In 1684, following the destruction of Tungning, other bans were lifted. The year after that, customs offices were established in Guangzhou, Xiamen, Ningbo, and Songjiang to deal with foreign trade.
Repressive Qing policies such as the queue caused Chinese traders to emigrate in such large numbers, however, that the Kangxi Emperor began to fear the military implications. The immigrant community in Jakarta was estimated at 100,000 and rumors circulated that a Ming heir was living on Luzon. A ban on trade in the "Southern Ocean" followed in 1717, with tighter port inspections and travel restrictions. Emigrants were ordered to return to China within the next three years upon penalty of death; those emigrating in future were to face the same punishment.
Legal trade in the South China Sea was resumed in 1727, but the East India Company's discovery that the prices and duties at Ningbo were both much lower than those at Guangzhou prompted them to begin shifting their trade north from 1755 to 1757. The Qianlong Emperor's attempt to discourage this through higher fees failed; in the winter of 1757, he declared that—effective the next year—Guangzhou (then romanized as "Canton") was to be the only Chinese port permitted to foreign traders, beginning the Canton System, with its Cohong and Thirteen Factories.
Nonetheless, it was quite harmful to the Chinese themselves, as documented in governors' and viceroys' memorials to the throne. Even before the Kangxi Emperor's restrictions, Jin Fu's 1659 memorial to the throne argued that the ban on foreign trade was limiting China's access to silver, harmfully restricting the money supply, and that lost trading opportunities cost Chinese merchants 7 or 8 million taels a year. The policies revived rebellions[which?] and piracy along the coast. The Great Clearance was completely disruptive to China's southern coasts. Of the roughly 16,000 residents of Xin'an County (roughly modern Shenzhen and Hong Kong) who were driven inland in 1661, only 1,648 were recorded returning in 1669. Powerful typhoons that year and in 1671 further destroyed local communities and discouraged resettlement. When trade restrictions were released, Fujian and Guangdong saw enormous outflows of migrants. The conflicts between the former residents and the newcomers such as the Hakka provoked lingering feuds that erupted into full-scale war in the 1850s and '60s and that fueled Guangdong's piracy into the 20th century.
The restrictions imposed by the Qianlong Emperor that established the Canton System were highly lucrative for Guangzhou's Cohong—the merchant Howqua became one of the world's wealthiest individuals—and normalized Guangzhou's tax base and inflow of foreign silver. By restricting imports mostly to bullion, however, it created strong pressure on the British—for whom tea had become the national drink over the course of the 17th century—to find any means possible to adjust the balance of trade. This turned out to be smuggled Indian opium, which became so lucrative and important that the viceroy Lin Zexu's vigorous enforcement of existing laws against it prompted the First Opium War and the beginning of the unequal treaties that restricted Qing sovereignty in the 19th century. The 1842 Treaty of Nanking is generally taken to have ended China's isolation, with the opening of the ports of Xiamen ("Amoy"), Fuzhou ("Fuchow"), Ningbo ("Ningpo"), and Shanghai, but legal trade continued to be limited to specified ports to the end of the dynasty.