Just as a heated solid will melt into a liquid and a liquid heated further will evaporate into a gas, so will a gas subjected to yet further thermal input become ionized. In other words, if the atoms or molecules of a gas are given sufficient thermal energy, particle collisions can tear individual electrons away from these neutral particles, so that the gas becomes a plasma, or a collection of negatively charged electrons and positively charged ions. Thus, the hot, dense fluid of the Sun's atmosphere becomes a plasma at sufficiently high altitudes, and that state is maintained as this atmosphere expands outward to form the solar wind.
Ultraviolet radiation can also kick electrons out of their atomic or molecular orbits. If a planet has a neutral atmosphere, that atmosphere acts as a shield against the ionizing effects of such radiation from the Sun. But at sufficiently high altitudes, the tenuous atmosphere is ionized by solar ultraviolet radiation to form the planetary ionosphere and magnetosphere. Thus, plasma is the primary constituent of both planetary magnetospheres and the interplanetary medium.