The 38-year-old was a free agent after leaving Sao Paulo over a wage dispute in September.
Alves previously spent eight seasons with Barcelona, winning 23 trophies at the club, including six La Liga titles and three UEFA Champions League trophies.
He becomes new Barcelona manager Xavi Hernandez’s first signing since taking over the club last week.
Alves will not be able to play for Barcelona until January but he will start training with the club from next week.
Barcelona published a statement announcing Alves' return, which read: "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.
"The club will announce the full details at his official presentation as a new FC Barcelona player."
Alves won league titles with Juventus and Paris Saint Germain before returning to his homeland.
"Almost five years of fighting like crazy to get to that point. I didn't know it would last so long, I didn't know it would be so hard," Alves wrote on Instagram.
"But I knew within my heart and within my soul that this day would come. I am coming back home to a place that I never left.
"See you soon with the same desire to help rebuild the best club in the world!"