Mental health is an important medical issue in perinatal care, and there is increasing evidence that insomnia during pregnancy is associated with postpartum depression (PPD). Therefore, the present study evaluated the effect of insomnia treatment during the third trimester of pregnancy on PPD symptoms. Fifty-four pregnant women with insomnia were randomly assigned to trazodone, diphenhydramine, or placebo treatment. Sleep quality was measured by actigraphy at baseline, and after 2 and 6 weeks of treatment. In addition, depression was assessed 2 and 6 weeks after delivery. Trazodone and diphenhydramine improved sleep profile compared to placebo after 6 weeks of treatment. Further, depressive symptoms were reduced 2 and 6 weeks after delivery in trazodone and diphenhydramine groups compared to placebo. No differences in depressive symptoms were observed between the trazodone and diphenhydramine groups. These findings indicate that insomnia treatment with trazodone or diphenhydramine during the third trimester of pregnancy may prevent PPD. © 2013 Elsevier Ireland Ltd.