This study focuses on the real-time operation of a microgrid (MG). A novel approximate dynamic programming based spatiotemporal decomposition approach is developed to incorporate efficient management of distributed energy storage systems into MG real-time operation while considering uncertainties in renewable generation. The original dynamic energy management problem is decomposed into single-period and single-unit sub-problems, and the value functions are used to describe the interaction among the sub-problems. A two-stage procedure is further designed for the real-time decisions of those sub-problems. In the first stage, empirical data is utilised offline to approximate the value functions. Then in the second stage, each sub-problem can make immediate and independent decision in both temporal and spatial dimensions to mitigate adverse effects of intermittent renewable generation in a MG. No central operator intervention is required, and the near optimal decisions can be obtained at a very fast speed. Case studies based on a six-bus MG and an actual island MG are conducted to demonstrate the effectiveness of the proposed algorithm.