An England international, Carrick won five Premier League titles at United under Alex Ferguson before joining Jose Mourinho's coaching staff after retiring as a player in 2018.
He was a key part of Solskjaer's management team and after the Norwegian's departure led United to a win at Villarreal in the Champions League which secured a place in the last 16 and Sunday's draw at Chelsea in the Premier League.
"We were in a situation where there was a responsibility to see these games through," said Carrick.
"I’ve had great times, great memories and I’m proud of the players over the past three games.
"I just told them and they were a bit shocked and surprised, a bit emotional in the changing room. I held it together just about. It’s not been easy to keep it away from people but I had a job to do," the 40-year-old said.
United's Football Director John Murtough said the club were sad to see him leave.
"Michael leaves with the sincerest thanks and best wishes of everyone at Manchester United after 15 years of exceptional service to the club as a player and as a coach. While we are sad to see him go, we respect and understand Michael’s decision," he said.