The Sun is primarily composed of hydrogen and helium, with hydrogen making up about 74% of its mass and helium about 24%. These elements are in a plasma state due to the Sun's extreme temperatures, and nuclear fusion in its core converts hydrogen into helium, releasing energy that powers the Sun.