Chinese migration to Japan grew dramatically after the implementation of the 1858 Ansei Treaties with the Euro-American powers (the so-called unequal treaties) and the opening of the treaty ports at Nagasaki, Yokohama, Kobe, Hakodate, and Niigata (the latter two under the terms of the Japan–US Treaty of Peace and Amity), as well as the foreign concessions in Tokyo and Osaka. In Nagasaki, resident Chinese were joined by compatriots employed as compradors or servants of Euro-American traders, by those who set up their own shops or trading firms, as well as by those who, lacking any employment, simply gained passage on Western ships bound for Japan. Comparable social topographies soon developed in Yokohama and Kobe. In fact, Chinese quickly came to comprise by far the largest group of foreigners in the treaty ports.
Popular images of the Chinese shifted over time. On the one hand, Chinese merchants were seen as kindly "Acha-san" who distributed gifts to children. But strangers could have dangerous as well as friendly aspects. Discourses on Chinese criminality soon spread, abetted by the new media of the Meiji era, which projected images of Chinese larceny, opium smuggling, and abduction and human trafficking, well out of proportion to the incidence of actual Chinese misbehavior. Geopolitical rivalry between Meiji Japan and Qing China, which culminated in Japan's victory in the 1894-95 Sino-Japanese War, also replaced earlier fears of Chinese power with increasingly racist depictions of the Chinese as uncivilized and less-than-human, even as popular enthusiasm for Chinese food grew rapidly.
The Chinese who came to Japan had to find ways to exist in a society marked by these divisions, even as they embodied them in their daily movements across Japanese space -- movements that were subjected to intensive police surveillance.
For a conceptual overview, see: Strangers.
On the historical ties between Fuqing/Fujian and Nagasaki and their uses in the present, see also this article on the Buddhist monk Ingen Ryūki.