Half a century has passed since the foundation of nuclear astrophysics. Since then, this discipline has reached its maturity. Today, nuclear astrophysics constitutes a multidisciplinary crucible of knowledge that combines the achievements in theoretical astrophysics, observational astronomy, cosmochemistry and nuclear physics. New tools and developments have revolutionized our understanding of the origin of the elements: supercomputers have provided astrophysicists with the required computational capabilities to study the evolution of stars in a multidimensional framework; the emergence of high-energy astrophysics with space-borne observatories has opened new windows to observe the Universe, from a novel panchromatic perspective; cosmochemists have isolated tiny pieces of stardust embedded in primitive meteorites, giving clues on the processes operating in stars as well as on the way matter condenses to form solids; and nuclear physicists have measured reactions near stellar energies, through the combined efforts using stable and radioactive ion beam facilities. This review provides comprehensive insight into the nuclear history of the Universe and related topics: starting from the Big Bang, when the ashes from the primordial explosion were transformed to hydrogen, helium, and few trace elements, to the rich variety of nucleosynthesis mechanisms and sites in the Universe. Particular attention is paid to the hydrostatic processes governing the evolution of low-mass stars, red giants and asymptotic giant-branch stars, as well as to the explosive nucleosynthesis occurring in core-collapse and thermonuclear supernovae, gamma-ray bursts, classical novae, X-ray bursts, superbursts, and stellar mergers.