Wild mammals in ex situ captivity experience substantially different environmental conditions compared to free-ranging conspecifics, e.g., in terms of diet, climatic conditions, social factors, movement space, and direct anthropogenic disturbance. Moreover, animals in captivity frequently undergo management interventions such as medical treatments which may influence pathogen pressure. Captivity is known to affect immunological responses in some terrestrial and marine mammals; however, it is unclear whether this can be generalized to other taxa. Furthermore, little is known about how energetically costly life history stages such as lactation influence the immune system in wildlife. We measured expression of components of the constitutive and induced innate immunity and of the adaptive immune system in plains and mountain zebras (Equus quagga and E. zebra), including lactating and non-lactating individuals. As a proxy for general immune function, we screened for lytic equine herpesvirus (EHV) infection, a common and often latent pathogen which is reactivated in response to stress and immune challenge. Both energetically cheap markers of the constitutive innate immunity were lower in captive than in wild zebras, whereas energetically costly markers of the induced innate immunity were more highly expressed in captive zebras. Lactation was associated with higher titers of natural antibodies and lysozyme. Lytic EHV infection was not significantly correlated with any of the measured immune markers. Our results suggest that captivity and lactation may influence immune functions in zebra mares.