Although research on the impacts of agricultural cooperatives is growing, studies on the effects of dairy cooperative membership on food security in developing countries remain scarce. This article follows the same line of inquiry to determine the impact of dairy cooperative membership on food and nutrition security (household dietary diversity score and food insecurity experience score) using data from 515 rural dairy farmers in Zambia. To account for selection bias issues, we use the endogenous switching Poisson regression model supplemented with the Poisson regression with endogenous treatment and machine learning techniques. Results indicate that age, education, dairy farming experience and participation in seminars on cooperatives positively influence dairy cooperative membership. Conversely, higher milk prices at collection centres are associated with a decreased likelihood of cooperative membership. We find that dairy cooperative membership increases dietary diversity and food security for a dairy farmer and dairy cooperative members as well as the non‐members if they joined dairy cooperatives. Further, dairy cooperative membership increases food and nutrition security for dairy farmers who join cooperatives because they are nearby. Collectively, our results support increased dairy cooperative development in rural areas to improve food and nutrition security of rural dwellers in developing countries.