BackgroundRapid urbanization of China has resulted in significant domestic migration. The purpose of the present study was to survey the sexual behavior of migrant workers in Shanghai and determine the risk factors for unprotected sex.MethodsA cross-sectional study of the sexual behavior of 5996 migrant workers was conducted in 7 administrative regions of Shanghai in 2012 from August to October. A self-administered questionnaire was used to collect data.ResultsFive thousand seven hundred seventy two out of the 5996 migrants enrolled into the present study were primarily young adults aged 34.3 ± 10.6 years. Of them, 73.5 % were married, 51.1 % graduated from junior high school, 46.0 % earned 1500–2500 yuan (RMB) monthly. The majority (82.3 %) of the migrants engaged in sexual behavior, and 58.0 % did not use condoms in sexual intercourse. Some of the participants (15.2 %) had casual extramarital partners within the previous 12 months; among them, 76.2 % never or only occasionally used condoms. The results of the multivariate logistic regression analysis suggested that condom use was associated with age, occupation, monthly income, education, and housing conditions. Having temporary sexual partners was significantly associated with several factors such as unmarried (OR: 0.47, 95 % CI: 0.38–0.57), working at domestic (OR: 1.65,95 % CI: 1.17–2.34), working at wholesale/retail(OR: 1.65, 95 % CI: 1.13–2.13), and male migrants (OR: 2.37, 95 % CI: 1.96–2.85), but not with other factors such as age, monthly income, or education. Having casual extramarital partners was significantly associated with female migrants working at domestic (OR: 1.89, 95 % CI: 1.09–3.28), unmarried male migrants (OR: 0.51, 95 % CI: 0.36–0.74).ConclusionCloser attention should be paid to sexual health education among migrant workers, especially women and those working in domestic and wholesale/retail occupations. The use of condoms should be promoted for older (>35 y), low-income, and less-educated individuals.