Background: In China, more than 10 million rural migrants move to cities every year. Because of the Household Registration System, migrant workers are not entitled to subsidised housing, education, social security or medical benefits.Aims: Using a resilience perspective, this study attempted to explore not only the migration stress that is experienced by migrant workers, but also the protective function of meaning of migration in helping migrant workers withstand the stress of migration.Method: A survey design with multistage cluster sampling was used and 475 migrant workers were recruited. The questionnaire contained demographic data, the Brief Symptom Inventory, a migration stress scale and meaning of migration scale.Results: Financial and employment difficulties stood out as the most stressful issues for migrant workers. More financial and material gains and personal aspirations and achievement were the most common reasons for living in Shanghai. Regression analyses revealed that financial and employment difficulties and interpersonal tensions and conflicts significantly predicted the mental health of both male and female migrant workers. In addition, while marital status significantly predicted the mental health of male migrant workers, the subscale `more financial and material gains' in the meaning of migration scale predicted the mental health of female migrant workers. Finally, there was a moderating effect of meaning of migration on the mental health of female migrant workers.Conclusion: There is a need to consolidate and develop policies to protect the rights of migrant workers in China. Mental health counselling for migrant workers who are experiencing difficulties living in Shanghai should be introduced.