Aim: The aim of this study was to examine the mediation effect of ego defense mechanisms on the relationship between secure, avoidant, and ambivalent attachment styles with alexithymia. Method: Method of the present study was correlational and the statistical population included about 4 million men and women aged 20 to 55 years living in Tehran. A total of 676 volunteers (314 men, 362 women) were included in this study. All participants were asked to complete Defense Styles Questionnaire (Andrews, Singh, & Bond, 1993), Adult Attachment Inventory (Hazan & Shaver, 1987), and Farsi version of the Toronto Alexithymia Scale (Bagby, Parker, & Taylor, 1994). Data was analysed using Pearson's correlation coefficients and regression analysis. Results: Secure attachment style showed a significant negative association with alexithymia, while avoidant and ambivalent attachment styles showed significant positive associations with alexithymia. Analysis of the data revealed that defense mechanisms mediated the relationship between attachment styles and alexithymia. It was shown that secure and insecure attachment styles can predict changes of alexithymia through mature, neurotic, and immature defense mechanisms in opposite directions. Conclusion: Based on the results of the present study, it can be concluded that mediation effect of ego defense mechanisms on the relationship between attachment styles and alexithymia was partial. Correlation coefficients between attachment styles and alexithymia were reduced by the mediation effect of ego defense mechanisms. However, this effect was partial and the correlation between attachment styles and alexithymia remained significant. In order to reconstruct processes of emotion regulation, it may be useful to try and increase secure attachment characteristics in indivuduals and encourage them to use more mature defense mechanisms.