The power system has gone through an evolutionary process towards a smart grid, this process is a challenge for the system operator, these challenges are related to implementation in real time, as well as problems with the control and stability of the system. We propose a distributed transactive control algorithm based on population games to dynamically manage the distributed generators and smart loads in the system to reach the optimum social welfare. The proposed algorithm preserve stability and guarantee optimality conditions considering several constraints on the real-time operation. Loads are modeled flexible and base loads. Stability analysis and Nash equilibrium of the proposed game is studied by means of potential games concepts. Simulation results of the proposed algorithm shows the stability and convergence of the proposed algorithm.