In this work, the combined effects of cooperation (energy aggregation) and storage in mitigating the fluctuations of renewable energy are examined under the setting of distributed energy generation. While cooperation exploits the diversity of renewable energy generation across space, storage exploits the diversity present across time. The trade-off between these two techniques examined, and the regimes under which the two techniques are optimal is investigated. While cooperation between the distributed generating units is restricted by the network power flow (NPF) constraints and thermal limits of the transmission lines, energy storage is in turn restricted by device capacity and imperfections. The problem is formulated as a stochastic optimization problem with the objective of minimizing the time average cost of energy exchange, subject to satisfying the user demands, the NPF and storage constraints. A DC power flow model is used to formulate the NPF constraints. A low complexity online solution to solve this problem is proposed based on the Lyapunov optimization technique, and analytical bounds on the performance of the algorithm are derived. The algorithm results are validated by performing extensive simulations using the IEEE benchmark bus systems. First the importance of incorporating NPF constraints while modeling MG cooperation are illustrated, and it is shown that ignoring them can lead to erroneous power sharing strategies. Then, the benefits of MG cooperation are illustrated in the presence of limited capacity power transmission lines. Further, it is observed that when the battery is inefficient, its utilization is low (regardless of the battery capacity), and most of the residual load is satisfied by exchanging energy among other elements within the grid. However, when the battery is efficient and has a large storage capacity, it is observed that most of the excess renewable energy is stored in the battery, and utilized locally at a future time. Under this regime, cooperation does not yield significant benefits.