Alves, whose previous deal was due to expire this month, was linked with other clubs that included Paris Saint-Germain, AC Milan and Manchester United.
Speaking after winning the Champions League on Saturday with their victory over Juventus, the 32-year-old discussed the possibility of a move to AC Milan.
“FC Barcelona has announced that Dani Alves has accepted its proposal for the renewal of his contract which expires on June 30. The new agreement binding both parties will be for a further two seasons, through to June 30, 2017, with the option of a third additional season,” the club’s website said.
Alves joined Barcelona from Sevilla in 2008 and has helped the club to five La Liga titles, as well as winning the Champions League and Copa del Rey three times apiece.