Xavi will take charge of the team's final La Liga match on Sunday at Sevilla before departing.
"Barcelona president Joan Laporta has told Xavi Hernandez he will not continue as coach for the 2024-25 season," said Barcelona in a statement.
Former Bayern Munich and Germany coach Hansi Flick is heavily tipped to replace Xavi.
"It's never easy to leave the club of your life, but I am very proud," said Xavi in an open letter published on social media.
"From Sunday I will be just one more Barca fan, in the stands, whether it's the Olympic Stadium or in a few months in the new Camp Nou.
"Because before being a player or a coach, I am a fan of Barcelona and I only want the best for the club, who will always have me at their disposal."
In January, Xavi said he would leave at the end of the season but, after a run of strong form, in April he and president Laporta agreed the coach would stay for the next campaign, with his contract expiring in June 2025.
However, the situation quickly changed with Spanish media reporting Laporta was angered by Xavi's comments suggesting it was hard for the financially-hamstrung club to compete with Real Madrid and other elite European sides.
"Barcelona want to thank Xavi for his work as coach, which adds to his unmatchable career as a player and the captain of the first team, and wish him all the best in the future," continued Barcelona's statement.
"In the coming days, Barcelona will reveal the new coaching structure for the first team staff."
Flick, 59, has not coached since Germany sacked him in 2023 after a poor run of results.
Previously Flick steered Bayern to a treble in 2020, including an 8-2 thrashing of Barcelona in the Champions League quarter-finals.
Barcelona won La Liga last season but were not able to successfully defend the title.
They were knocked out of the Champions League in the quarter-finals by Paris Saint-Germain, were hammered by Real Madrid in the Spanish Super Cup final and lost to Athletic Bilbao in the Copa del Rey.
When Xavi, 44, made his U-turn to stay, it appeared he and Barcelona were remaining together in a marriage of convenience.
"It's great news that Xavi is staying," said Laporta on April 25.
"The team we have... with very young players, needs that stability.
"Today I'm especially pleased, and the board have unanimously supported this decision."
Less than a month later Barcelona's fiery president changed his mind.
'How badly Barca treats legends'
Xavi insisted over the past fortnight he was still looking forward to coaching the club next season and felt he had the confidence of Laporta.
Barcelona's chief appointed Xavi in November 2021 to replace Ronald Koeman, aiming to return the club to its pedestal after years of struggles in Europe following their 2015 Champions League triumph.
As a player Xavi made 767 appearances for the Catalan club, behind only Lionel Messi, winning eight La Liga titles and four Champions Leagues among other trophies.
For years Xavi insisted his dream was to coach Barcelona but in January he said the job was "cruel" and took a toll on him mentally.
Sevilla coach Quique Sanchez Flores said he would give Xavi a warm embrace on Sunday and he believes the sacking was another example of Barcelona treating their legends badly.
"I shouldn't say this, but how badly Barcelona treats their legends, what a bad streak," said the coach.
"With Koeman, with Messi, with Xavi now. I wish clubs treated their legends well -- it would be fantastic."
Manchester City coach Pep Guardiola, in charge at Barcelona during the peak of the club's success with Xavi in midfield, said it was "not good news".
"When one club sacks the manager something is wrong but the reasons, what happened, I don't know so I can't give an opinion," Guardiola told reporters at his eve of FA Cup final press conference in London.
"We are exposed - in our job you have to win otherwise you are in a dangerous position, whatever club, no matter your trajectory."