Urban gardens can support diverse bee communities through resource provision in resource poor environments. Yet the effects of local habitat and landscape factors on wild bee communities in cities is still insufficiently understood, nor is how this information could be applied to urban wildlife conservation. Here we investigate how taxonomic and functional diversity of wild bees and their traits in urban community gardens are related to garden factors and surrounding landscape factors (e.g., plant diversity, amount of bare ground, amount of nesting resources, amount of landscape imperviousness). Using active and passive methods in 18 community gardens in Berlin, Germany, we documented 26 genera and 102 species of bees. We found that higher plant species richness and plant diversity as well as higher amounts of deadwood in gardens leads to higher numbers of wild bee species and bee (functional) diversity. Furthermore, higher landscape imperviousness surrounding gardens correlates with more cavity nesting bees, whereas a higher amount of bare ground correlates with more ground‐nesting bees. Pollen specialization was positively associated with plant diversity, but no factors strongly predicted the proportion of endangered bees. Our results suggest that, aside from foraging resources, nesting resources should be implemented in management for more pollinator‐friendly gardens. If designed and managed using such evidence‐based strategies, urban gardens can create valuable foraging and nesting habitats for taxonomically and functionally diverse bee communities in cities.