The Norwegian, 45, arrived at Old Trafford on an interim basis in December to replace Jose Mourinho.
Solskjaer spent 11 seasons as a United player, scoring the winning goal in the 1999 Champions League final.
“This is the job that I always dreamed of doing and I’m beyond excited to have the chance to lead the club long term,” Solskjaer said.
“From the first day I arrived, I felt at home at this special club. It was an honour to be a Manchester United player, and then to start my coaching career here.
“The last few months have been a fantastic experience.”
When Solskjaer took charge, United were sixth in the Premier League and 11 points off the top four.
But they have lost only once in 13 league games since – at Arsenal this month – and are now two points behind the London club, who occupy the final Champions League qualifying spot.
Solskjaer is the first United manager to win his first six league games, beating a record held by Sir Matt Busby.
United reached the quarter-finals of the Champions League for the first time since 2014, after they overturned a 2-0 first-leg deficit thanks to a stoppage-time penalty at Paris St-Germain this month.