The Duke of Cambridge said in a statement the couple “could not be happier”. He and the duchess will remain in the hospital overnight.
The news has been displayed on an easel in the forecourt of Buckingham Palace in line with tradition.
A bulletin – signed by the Queen’s gynaecologist Marcus Setchell, who led the medical team that delivered the baby – was taken by a royal aide from St Mary’s to the palace under police escort.
The document said: “Her Royal Highness, the Duchess of Cambridge was safely delivered of a son at 4.24pm today.
“Her Royal Highness and her child are both doing well.”
When the news was announced, a large cheer went up from well-wishers and journalists outside the hospital while a large crowd greeted the posting of the bulletin outside Buckingham Palace.
The Kensington Palace press release said the Duke of Cambridge was present for the birth of his son, who will be known as the Prince of Cambridge and who is third in line to the throne.
“The Queen, The Duke of Edinburgh, The Prince of Wales, The Duchess of Cornwall, Prince Harry and members of both families have been informed and are delighted with the news,” it said.
A Kensington Palace spokesman said the names of the baby – who was delivered in the private Lindo Wing of St Mary’s – would be announced in due course.
The Prince of Wales, in a separate statement, said he and the Duchess of Cornwall were “overjoyed at the arrival of my first grandchild.
“It is an incredibly special moment for William and Catherine and we are so thrilled for them on the birth of their baby boy,” he added.
“Grandparenthood is a unique moment in anyone’s life, as countless kind people have told me in recent months, so I am enormously proud and happy to be a grandfather for the first time and we are eagerly looking forward to seeing the baby in the near future.”
BBC royal correspondent Peter Hunt said the duke and duchess spent time bonding with their son before they told the family their news.
Royal doctor Mr Setchell described the new arrival as “wonderful baby, beautiful baby”, our correspondent added.
Prime Minister David Cameron, speaking outside Downing Street, hailed the “wonderful news”.
“It is an important moment in the life of our nation but I suppose, above all, it’s a wonderful moment for a warm and loving couple who’ve got a brand new baby boy,” he added.
He said the Royal Family could “know that a proud nation is celebrating with a very proud and happy couple tonight”.
Scottish First Minister Alex Salmond said: “I am sure that people across Scotland will be absolutely thrilled to hear the news of the birth of a baby boy to the Royal couple and will want to join me in wishing the proud parents many congratulations.”
And Welsh First Minister Carwyn Jones congratulated the couple “on behalf of the people of Wales” as “they enter their journey into parenthood”.
The Archbishop of Canterbury, meanwhile, said he was “delighted to congratulate the Duke and Duchess of Cambridge on the arrival of their baby boy”.
“Along with millions here and around the world, I share in their joy at this special time,” he added.
“May God bless this family with love, health and happiness in their shared life ahead.”
Catherine and Prince William had arrived at the hospital at 06:00 BST ahead of a Kensington Palace announcement that she was in the early stages of labour.
The world’s media had been camped outside St Mary’s for days in anticipation of the birth.