The goalkeeper looked certain to depart Old Trafford in the summer after initially turning down United’s offer of a new deal.
Real Madrid had been pursuing the 24-year-old and agreed a fee for his services on the last day of the Spanish transfer window.
But the deal collapsed after the relevant paperwork was not filed before the La Liga deadline.
And now he has put pen-to-paper on a four-year contract, with the option of a further year – news which will delight fans of the Premier League club.
De Gea said on his new deal: “I am delighted to be starting this new chapter in my United career.
“I have always enjoyed playing with these great players in front of our fantastic fans. Manchester United is a special club and Old Trafford is an ideal place for me to continue to develop my career.
“I’m looking forward to putting a difficult summer behind me and concentrating on working hard to improve and help my teammates to be successful.”
Van Gaal added: “I am absolutely delighted David has signed a new contract. He is one of the best goalkeepers in world football.
“I am very pleased that he will be part of the team for many years to come.
“David made a very important contribution to our performance last season and he has been the club’s Player of the Year for the last two seasons. He is a popular player who is keen to learn and enhance his game.
“At such a young age for a goalkeeper, he has many years ahead of him.”
Sergio Romero has played in United’s six games this season but he now looks certain to make way for De Gea for Saturday’s visit of Liverpool.