The first wave of Chinese immigrants arrived in the United States in the late 1840s, and remained throughout the 1850s for the California Gold Rush. The first Chinese ship to arrive in San Francisco came in 1848, but initial immigration was slow. In 1851, for example, only 2,716 immigrants arrived. After a crop failure in southern China brought famine, 20,026 Chinese immigrated to San Francisco in 1852. Many headed to nearby gold mines for work, where they often faced discrimination. Despite making up 20 percent of San Francisco's population by the end of the 1850s, the Chinese were routinely robbed at the mines, and faced a $3 Foreign Miners Tax that was specifically designed for the Chinese.
The construction of the transcontinental railroad in the 1860s was completed primarily by immigrant labor, many of whom were Chinese. The Chinese worked mainly on the Central Pacific half of the line, and their contribution was significant. At the height of construction in 1868, for example, Chinese immigrants made up 80 percent of the Central Pacific's workforce. They faced significant discrimination, such as a ban on holding citizenship in California. In addition, the Chinese were paid only $27 a month, while their Irish immigrant counterparts earned $35 for the same work.
In the 1870s, Chinese immigrants were an established presence in many parts of California, but discrimination and hardship only worsened. The 1870s were a time of high unemployment and economic depression, and this contributed to resentment between races. Many whites also began to perceive the Chinese as criminals, partly because of a rise in the number of Chinese prostitutes. This resulted in a series of laws restricting immigration, such as the Page Law of 1875 that forbade immigration from Asia for "lewd and immoral purposes."
By the 1880s, restrictive laws such as the Page Law were considered insufficient, and many Americans wanted to ban Chinese immigration altogether. The 1868 Burlingame-Seward Treaty between the United States and China, however, forbade the United States from banning Chinese immigrants. This was overturned in 1880 with the signing of the 1880 Angell Treaty. With diplomatic restrictions lifted, Congress was able to pass the Chinese Exclusion Act in 1882, which banned all Chinese immigration for a 10-year period. Restrictions only increased thereafter, with laws such as the Scott Act, which banned legal Chinese-American residents from re-entering the United States after a visit to China.