Australian driver Daniel Ricciardo. AFP
The 33-year-old, who joined in 2021, said he will leave "proud of the effort and work I gave McLaren."
Ricciardo has eight career wins, including one for McLaren last year -- the Italian Grand Prix.
He has been largely played second fiddle to team-mate Lando Norris. The English driver has 76 points compared to Ricciardo's 19.
Norris finished sixth in last year's championship on 160 points with Ricciardo eighth on 115 points.
"It's been a privilege to be a part of the McLaren Racing family for the last two seasons," said Ricciardo in a statement issued by the team.
"Following several months of discussions with Zak (Brown the CEO) & Andreas (Seidl the team principal) we have decided to terminate my contract with the team early and agree to mutually part ways at the end of this season.
"I'll be announcing my own future plans in due course but regardless of what this next chapter brings, I have no regrets and am proud of the effort and work I gave McLaren, especially the win in Monza, last season."
Seidl paid tribute to Ricciardo's positive attitude.
"Despite the shared challenges, he has always turned up with a fighting spirit and positivity and helped the entire team to always keep pushing forward," said Seidl.
"We will never forget that memorable race win in Monza which was a great boost for the whole team."
Brown said it had been a pleasure to work with Ricciardo.
"It's no secret that we hoped we could achieve more together," said Brown.
"But seeing him stand on the top step of the podium as a McLaren driver was a highlight.
"We wish him well for the future and let's go enjoy the rest of the season together."
Ricciardo and Norris will be back in action this weekend at the Belgian Grand Prix.
(For more sports news and updates, follow Ahram Online Sports on Twitter at @AO_Sports and on Facebook at AhramOnlineSports.)