Energy systems face great challenges from both the supply and demand sides. Strong efforts have been devoted to investigate technological solutions aiming at overcoming the problems of fossil fuel depletion and the environmental issues due to the carbon emissions. Hybrid (activated by both renewables and fossil fuels) distributed energy systems can be considered a very effective and promising technology to replace traditional centralized energy systems. As a most peculiar characteristic, they reduce the use of fossil sources and transmission and distribution losses along the main power grid and contribute to electric peak shaving and partial-loads losses reduction. As a direct consequence, the transition from centralized towards hybrid decentralized energy systems leads to a new role for citizens, shifting from a passive energy consumer to active prosumers able to produce energy and distribute energy. Such a complex system needs to be carefully modelled to account for the energy interactions with prosumers, local microgrids and main grids. Thus, the aim of this paper is to investigate the performance of a hybrid distributed energy system serving an urban community and modelled within the framework of agent-based theory. The model is of general validity and estimates (i) the layout of the links along which electricity is distributed among agents in the local microgrid, (ii) electricity exchanged among agents and (iii) electricity exported to the main power grid or imported from it. A scenario analysis has been conducted at varying the distance of connection among prosumers, the installed capacity in the area and the usage of links. The distributed energy system has been compared to a centralized energy system in which the electricity requests of the urban community are satisfied by taking electricity from the main grid. The comparison analysis is carried out from an energy, environmental and economic point of view by evaluating the primary energy saving, avoided carbon dioxide emissions and the simple payback period indices.