The 27-year-old had been keen to seek assurances from manager Ole Gunnar Solskjaer about playing time and sources told ESPN that a breakthrough in negotiations was made last week.
"I'm very happy," Bailly said. "This decision is something I didn't have to think about, I love this club and I love playing for Manchester United. I'm happy and so are my family, everything is good. Now the moment with my injury has passed and I'm fit and feel good, and that's it. A new contract is like a new challenge and I'm ready for this.
"I hope I can be ready and I don't get any injuries and to be strong and finish the season well. I hope to win the Europa League this season. We will have more challenges next season -- hopefully the Champions League -- and, for me, my dream is to win the Premier League, that's my big dream."
Bailly, a £30 million signing from Villarreal in 2016, was due to enter the final year of his contract this summer. His situation had alerted clubs in Italy and Spain ahead of the transfer window. The centre-back is keen to play more regularly after being restricted to just eight Premier League appearances this season and 15 in all competitions.
"I am pleased that Eric has signed this new contract. He is still learning and improving all of the time under the coaches here," Solskjaer said.
"Eric has improved his robustness since my time as manager and he will continue to play a significant part in the squad.
"He possesses fantastic speed, timing of tackle and has that aggression which, of course, you need as a centre-back. He is a popular member of the squad and we look forward to continuing to work with him going forward."
The club have had concerns about Bailly's injury record after making just 37 Premier League appearances since the start of the 2017-18 season. He tested positive for coronavirus while on international duty with the Ivory Coast and after returning to training last week was an unused substitute for the 0-0 draw with Leeds United on Sunday.
United allowed Marcos Rojo join Boca Juniors in January, but Solskjaer still has five centre-backs in his first-team squad.
Maguire and Lindelof have been first choice for much of the campaign with Bailly and Axel Tuanzebe providing back-up. Phil Jones has not played a competitive game for more than a year after a troublesome knee injury and still has two years plus a one-year option on his contract.
The 29-year-old England international has returned to training, but will have to build up his fitness before he is considered for a return to first-team action.