The hygiene hypothesis postulates that the recent increase in allergic diseases such as asthma and hay fever observed in Western countries is linked to reduced exposure to childhood infections. Here we investigated how infection with a gammaherpesvirus affected the subsequent development of allergic asthma. We found that murid herpesvirus 4 (MuHV-4) inhibited the development of house dust mite (HDM)-induced experimental asthma by modulating lung innate immune cells. Specifically, infection with MuHV-4 caused the replacement of resident alveolar macrophages (AMs) by monocytes with regulatory functions. Monocyte-derived AMs blocked the ability of dendritic cells to trigger a HDM-specific response by the T(H)2 subset of helper T cells. Our results indicate that replacement of embryonic AMs by regulatory monocytes is a major mechanism underlying the long-term training of lung immunity after infection.