The Spaniard left Camp Nou to play for Al Sadd in 2015, after making 767 appearances for the Catalan club, which included winning eight La Liga titles and four Champions Leagues, AFP reported.
"It's time to come home. Welcome, Xavi," Barca tweeted.
"It wasn't goodbye, it was see you later," it wrote, along with a video montage of the player's departure in 2015.
Barcelona said in a statement it had reached an agreement with Xavi to become first team coach for the rest of the current season and two more seasons, replacing the sacked Ronald Koeman.
"It is expected that Xavi Hernandez will arrive in Barcelona this weekend and that on Monday 8 November his presentation as new FC Barcelona first team coach will take place in an event open to the public at Camp Nou," it said.
Nicknamed the "Maquina" (the Machine), Xavi is widely considered one of the club's greatest ever players and there is huge excitement about his potential as a coach after his influence on the iconic Barca team managed by Pep Guardiola.
His passing style was seen as the embodiment of Guardiola's "tiki-taka" team that won the treble in 2009.
"One of the greatest midfield maestros of all time, he helped redefine the art with his creative mind, pinpoint passing and sublime ability to read the game," Barca said in their statement, heralding the return of "an absolute legend".
Qatari club Al Sadd, which Xavi had coached since 2019, hours earlier said they had reached an agreement with Barca and posted photos on social media of the Spaniard saying goodbye to the players and staff.
Barcelona's attempt to appoint Xavi as coach had been held up on Friday over his Al Sadd release clause, with Xavi and Barca considering splitting the payment to complete the deal.
Al Sadd said Barca had agreed to pay the clause in Xavi's contract, which is reportedly set at around €5 million ($5.8 million), but Barcelona did not give any details of the deal in their statement.
Xavi had made no secret of his desire to return to Barcelona, which he joined through the club's La Masia academy at the age of 11.
"My main objective, when I can do it, is Barca," Xavi told the sports daily Marca last year. "It's my home, that's the dream."
There are high hopes Xavi can draw on his incredible playing career to revive Barcelona, who currently sit ninth in La Liga, with concerns growing they might not finish in the top four.
The club are also in dire financial straits, having posted debts of 1.35 billion euros.
Xavi faces a formidable challenge after Barcelona let Lionel Messi join Paris Saint-Germain in the summer.
In Europe, Barca face a fight even to qualify for the knock-out stages of the Champions League while any rebuild will have to be carried out on a shoestring budget as the club struggles to deal with the debts it partly built up paying Messi's wages.
Xavi will also be charged with improving the team's style of play, which was a key criticism during the tenure of Koeman, another former Barca player.