The relationship between mastitis and functional longevity was assessed with survival analysis on data of Danish Black and White dairy cows. Different methods of including the effect of mastitis treatment on the culling decision by a farmer in the model were compared. The model in which mastitis treatment was assumed to have an effect on functional longevity until the end of the lactation had the highest likelihood, and the model in which mastitis treatment had an effect for only a short period had the lowest likelihood. A cow with mastitis had 1.69 times greater risk of being culled than did a healthy herdmate with all other effects being the same. A model without mastitis treatment was used to predict transmitting abilities of bulls for risk of being culled, based on longevity records of their daughters, and was expressed in terms of risk of being culled. The correlation between the risk of being culled and the national evaluations of the bulls for mastitis resistance was approximately -0.4, indicating that resistance against mastitis was genetically correlated with a lower risk of being culled and, thus, a longer functional length of productive life.