Human milk provides infants with various immune molecules. The objective of the present study was to measure human β-defensin-1 (hBD-1) and human β-defensin-2 (hBD-2) levels in the colostrum and mature milk of healthy Han Chinese, to identify factors regulating milk hBD-1 and hBD-2 expression and to explore the potential protective effect of milk hBD-1 and hBD-2 on infants. A total of 100 mothers and their babies were recruited into the study. Sociodemographic characteristics and other factors were obtained by a questionnaire. Babies were followed up for a period of 6 months. Colostrum samples (n 100) and mature milk samples (n 82) were collected by hand expression. The hBD-1 and hBD-2 concentrations were measured by ELISA. The hBD-1 and hBD-2 levels differed in the colostrum and mature milk. In the colostrum, the concentration ranges of hBD-1 and hBD-2 were 1·04–12·81 μg/ml and 0·31–19·12 ng/ml, respectively. In mature milk, the hBD-1 and hBD-2 levels were 1·03–31·76 ng/ml and 52·65–182·29 pg/ml, respectively. Several independent factors influence their production. The multivariable analysis showed a strong association between pre-pregnancy BMI and hBD-1 levels in the colostrum (P= 0·001), mode of delivery was significantly associated with hBD-2 levels in the colostrum (P= 0·006) and gestational age was significantly associated with hBD-1 levels in mature milk (P= 0·010). During the first 6 months of life, the incidence rate of upper respiratory infection was found to be less in the high-colostrum hBD-1 group than in the low-colostrum hBD-1 group (χ2= 4·995, P= 0·025). The present study suggested that the abundance of hBD-1 in the colostrum may have a protective function against upper respiratory infection for infants younger than 6 months.