Due to its great potential to improve the overall performance of data transmission with its dynamic and adaptive spectrum allocation capability in comparison with many other networking technologies, cognitive radio (CR) networking technology has been increasingly employed in networking and communication infrastructures for smart grids. However, a secondary user (SU) of a CR network has to be squeezed out from a channel when a primary user reclaims the channel, which may occur in a randomized fashion. The random interruption of SU traffic may cause packet losses and delays for SU data, and it will in turn affect the stability of the monitoring and control of smart grids. In this paper, we address this problem and investigate the modeling and stability analysis of the automatic generation control (AGC) of a smart grid for which CR networks are used as the infrastructure for the aggregation and communication of both system-wide information and local measurement data. For this purpose, a randomly switched power system model is proposed for the AGC of the smart grid. By modeling the CR network as an On–Off switch with sojourn times, the stability of the AGC of the smart grid is analyzed. In particular, we investigate the smart grid with two main types of CR networks: 1) the sojourn times are arbitrary but bounded and 2) the sojourn times follow an independent and identical distribution process. The sufficient conditions are obtained for the stability of the AGC of the smart grid with these two CR networks, respectively. Simulation results show the effects of the CR networks on the dynamic performance of the AGC of the smart grid and illustrate the usefulness of the developed sufficient conditions in the design of CR networks in order to ensure the stability of the AGC of the smart grid.