We investigate the formation and evolution of dwarf galaxies in a high-resolution, hydrodynamical cosmological simulation of a Milky Way sized halo and its environment. Our simulation includes gas cooling, star formation, supernova feedback, metal enrichment and ultraviolet heating. In total, 90 satellites and more than 400 isolated dwarf galaxies are formed in the simulation, allowing a systematic study of the internal and environmental processes that determine their evolution. We find that 95 per cent of satellite galaxies are gas free at z= 0, and identify three mechanisms for gas loss: supernova feedback, tidal stripping and photoevaporation due to re-ionization. Gas-rich satellite galaxies are only found with total masses above ∼5 × 109 M⊙. In contrast, for isolated dwarf galaxies, a total mass of ∼109 M⊙ constitutes a sharp transition; less massive galaxies are predominantly gas free at z= 0, more massive, isolated dwarf galaxies are often able to retain their gas. In general, we find that the total mass of a dwarf galaxy is the main factor which determines its star formation, metal enrichment and its gas content, but that stripping may explain the observed difference in gas content between field dwarf galaxies and satellites with total masses close to 109 M⊙. We also find that a morphological transformation via tidal stripping of infalling, luminous dwarf galaxies whose dark matter is less concentrated than their stars cannot explain the high total mass-to-light ratios of the faint dwarf spheroidal galaxies.