Iberian man-made oak savannahs (so called dehesas) are traditional silvopastoral systems with a high natural value. Scattered trees provide shelter and additional food to livestock (cattle in our study sites), which also makes possible for animals depending on trees in a grass-dominated landscape to be present. We compared dehesas with nearby treeless grasslands to assess the effects of oaks on ant communities. Formica subrufa, a species associated with decayed wood, was by far the most abundant species, especially in savannahs. Taxa specialized in warm habitats were the most common both in dehesas and grasslands, as expected in areas with a Mediterranean climate. Within dehesas, the number of species was higher below oak canopies than outside tree cover. Compared to treeless grasslands, the presence of oaks resulted in a higher species richness of aphid-herding and predator ants, probably because trees offer shelter and resources to predators. The presence of oaks changed also the species composition, which differed between grasslands and dehesas. In self-standing scattered oaks, ant communities did not differ between the trunks and soil below canopies. These results stress the conservation value of trees in dehesas; within grasslands, they offer an additional microhabitat for species that would otherwise be scarce or absent.