Answer:
By nuclear fusion the nuclei of the star masses fuse into each other producing a high energy that creates an outward pressure which releases in the space as electromagnetic radiation that keeps the star alive.
Step-by-step explanation:
As the gravitational pull gathers gas and dust and forms a huge ball, the temperature of the ball increases immensely causing a nuclear fusion. Through this fusion the contraction in the gas and dust increases ultimately crashing the nuclei of the electrons into each other and fusing them.
A great amount of energy is released in the process that creates a pressure outwardly and balances the inward gravity. When this energy moves out of the outer layer and reaches space it creates electromagnetic radiation that makes the star bright and intact in their position.