Presents the lecture notes of the 34th Saas-Fee Advanced Course. Emphasis is on the observed variability of the Sun, and the understanding of the variability's origin, as well as its impact on the Earth's climate. The solar variability is then studied in the broader context of solar-type stars.