The problem of partitioning a power grid into a set of islands can be a solution to restore power dispatchment in sections of a grid affected by an extreme failure. Current solutions to this problem usually involve finding the partition of the grid into islands that minimizes the sum of their absolute power imbalances. This combinatorial problem is often solved through heuristic centralized methods. In this paper, we propose instead a distributed online algorithm through which nodes can migrate among islands, self-organizing the network into a suitable partition. We prove that, under a set of appropriate assumptions, the proposed solution yields a partition whose absolute power imbalance falls within a given bound of the optimal solution. We validate our analytical results by testing our partitioning strategy on the IEEE 118 and 300 benchmark problems.