This chapter studies the problem of frequency regulation in power grids in the presence of unknown and uncontrollable generation and demand. We propose distributed controllers such that frequency regulation is achieved, while maximising the ‘social welfare’, i.e. maximising the utility of consuming power minus the cost of producing power. The controllable generation and loads are modeled as the output of a first-order system, which includes a widely used model describing the turbine-governor dynamics. We formulate the problem of frequency regulation as an output agreement problem for distribution networks and address it using incremental passivity, enabling a systematic approach to study convergence to the steady state with zero frequency deviation. In order to achieve optimality, the distributed controllers are utilising a communication network to exchange relevant information. The academic case study provides evidence that the performance of the controllers is good.