The present work introduces an empirically ground agent-based modeling (ABM) framework to assess the spatial and temporal diffusion of rooftop photovoltaic (PV) systems on existing buildings of a city district. The overall ABM framework takes into account social, technical, environmental, and economic aspects to evaluate the diffusion of PV technology in the urban context. A city district that includes 18 720 households distributed over 1 290 building blocks and a surface area of 2.47 km2 is used to test the proposed ABM framework. Results show how the underlying regulatory framework (i.e., the rules of the internal electricity market) influences the pattern and intensity of adoption, thus realizing different shares of the available potential. Policies that support the establishment of 'prosumers' within Condominiums (i.e., energy community buildings), and not in single-family houses only, is key to yield high diffusion rates. The installed capacity increases by 80% by switching from the one-to-one configuration to the one-to-many paradigm, i.e., from 5.90 MW of rooftop PV installed on single-family households and/or single PV owners to 10.64 MW in energy community buildings. Moreover, the possibility to spread the auto-generated solar electricity over the load profile of the entire population of Condominium results in self-consumption rates greater than 50% and self-sufficiency ratios above 20% for the majority of the simulated buildings. INDEX TERMS Agent-based modeling, complex adaptive systems, consumer behavior, distributed power generation, energy technology diffusion, geospatial analysis, photovoltaic systems, public policy, sustainable development, technology adoption, urban areas.