Urban agriculture is becoming increasingly important in developed countries, especially in terms of its economic and social benefits. If urban gardens are managed according to agroecological principles - involving the efficient and sustainable use of local resources and inputs - there are many environmental benefits to local communities. We studied urban gardens in Berkeley, California, and Madrid, Spain, to see how agroecology is practiced. Communities such as these that utilize good ecological practices in urban gardens obtain a wide range of valuable ecosystem services - the kinds of services provided by healthy ecosystems, including cultural services such as a place to socialize. These communities can serve as model urban agricultural centers which can contribute to the achievement of the United Nations Sustainable Development Goals, including good health, food security and sustainable cities.