We aimed to explore if first- and second-generation immigrants have similar risks of mental disorder in pregnancy and postpartum as native Danes have. A population-based cohort study merging data from two Danish population registers was conducted, and survival analyses were performed. A total of 736,988 women were classified as native Danes, first- or second-generation immigrants. The main outcome measure was incident psychiatric in- or outpatient contacts during pregnancy or 0-12 months postpartum. First- and second-generation immigrant mothers had a higher overall risk of psychiatric contacts during both pregnancy and postpartum compared to native Danish mothers. Additionally, in native Danes as well as first- and second-generation immigrant new mothers, the highest risk of psychiatric in- or outpatient contact with a mental disorder was 0-29 days postpartum (RR, 3.09 (95% CI, 2.75-3.48); 2.91 (95% CI, 2.20-3.86); 4.55 (95% CI, 3.33-6.24), respectively), after which the risk decreased with time since childbirth. The increased risk of mental disorders shortly after childbirth applied to native Danish mothers as well as first- and second-generation immigrant mothers. Moreover, overall immigrants conferred a higher risk of psychiatric contact throughout the entire perinatal period.