The Sun formed about 4,6 billion years ago from a giant cloud of gas and dust that contracted under its own gravity.