The 44-year-old delivered the bombshell news immediately after the Blaugrana's 5-3 La Liga loss to Villarreal, which left the reigning champions 10 points behind Real Madrid in third place in the La Liga table.
Xavi's job had been under intense scrutiny for several weeks, and even though the Spaniard's contract is not due to expire until the end of next season, he will no longer be in charge of the Catalonian giants beyond the summer.
Having overseen a third loss from five games at the Barcelona helm, Xavi admitted to the press that the club would benefit from a change in direction, and he "cannot allow the current situation" as a lifelong fan.
"I want to announce that on June 30 I will no longer continue as the coach at Barça. I think the situation needs to change course, and as a culer, I cannot allow the current situation," Xavi told the media.
"This club needs a change of dynamic. Leaving Barca is the best decision possible for all parties involved. I'm the most responsible one, so the players will finally feel free now."
Barcelona welcomed Villarreal to Estadi Olimpic Lluis Companys on the back of a humbling 4-2 extra-time defeat to Athletic Bilbao in the Copa del Rey, while they were also battered 4-1 by Real Madrid in the final of the Spanish Super Cup earlier this month.
The Blaugrana fell two goals down in Saturday's game to Gerard Moreno and Ilias Akhomach's efforts, but Xavi's side would seemingly pull off an astonishing comeback thanks to strikes from Ilkay Gundogan and Pedri, as well as an Eric Bailly own goal.
However, Goncalo Guedes drew Villarreal level again in the 84th minute, before a chaotic injury-time period saw Alexander Sorloth and Jose Luis Morales hammer the final nails into Xavi's coffin.
As well as having 10 points to make up to leaders Real Madrid, Barcelona sit eight behind second-placed Girona, but they finished top of their Champions League group and will meet another faltering national champion in Napoli for the last 16 next month.
Having ended speculation over his future by taking the decision into his own hands, Xavi believes that Barcelona's bid for European glory will benefit from the absence of uncertainty.
"Everything will be calmer now, we can compete for the Champions League... at least with this decision you [the press] won't kill me anymore," the 44-year-old added. "The club will improve with this decision."
During his playing pomp, Xavi made 767 appearances over a 17-year spell at Barcelona - second only to Lionel Messi's 778 - before ending his illustrious Camp Nou stint in 2015 to join Qatari outfit Al-Sadd.
The Spaniard hung up his boots in 2019 to take over as Al-Sadd head coach, spending just over two years in charge before being lured back to Barcelona in November 2021, replacing Ronald Koeman at the helm.
Xavi failed to deliver success to Barcelona in what remained of the 2021-22 season, as La Blaugrana were dumped out of the Europa League by Eintracht Frankfurt in the quarter-finals, and they suffered further continental disappointment in 2022-23, losing in the knockout round playoffs to Manchester United.
However, the former Spain international achieved La Liga glory with Barcelona last term, as La Blaugrana finished with 88 points - 10 clear of Real Madrid - to win their first title since the 2018-19 season.
Xavi also masterminded Barca's Supercopa de Espana win in 2022-23 and boasts a 61.48% win rate from 122 games in charge, posting 75 victories, 21 draws and 26 defeats.
The 44-year-old's announcement comes only a day after Liverpool boss Jurgen Klopp delivered a similar bolt from the blue, as the German confirmed that he would also step down from his position this summer.