The Brazil international, 38, had been a free agent since leaving Sao Paulo in September.
Sources previously told ESPN that Barca were reluctant to bring back Alves, but the return of Xavi, who was appointed as manger last week following the sacking of Ronald Koeman, caused a change of opinion.
The club said in a statement: "FC Barcelona and Dani Alves have reached an agreement in principle for the player to join the football first team for the remainder of the current season. The Brazilian will be joining training from next week but will not be able to play until January.
Back in DA house! pic.twitter.com/qicb8RRc1h— FC Barcelona (@FCBarcelona) November 12, 2021
"The club will announce the full details at his official presentation as a new FC Barcelona player."
Sources have told ESPN that Xavi will be given less than €10 million to strengthen the faltering squad in January, despite chief executive Ferran Reverter saying earlier this year that the club would have double that amount.
Circumstances around the club's January budget changed with lucrative extensions to young stars Ansu Fati and Pedri, although the costs involved in firing Koeman and hiring Xavi will not have a major effect on spending moving forward, sources have said.
He later had a spell with Paris Saint-Germain before leaving in 2019 to spend two years with Sao Paulo.
With the World Cup in Qatar next year, Alves, who won an Olympic gold medal with his country this past summer, is keen to find top-level football in a bid to make Tite's squad for the tournament.