A three-time Champions League winner with Barcelona, he had previously enjoyed international success in the Confederations Cup and the Copa America, but the Olympic final was the first time he came out on top in a global tournament.
Brazil's 38-year-old captain, who had led the team as an over-age player, collapsed to his knees at the final whistle and buried his face in his hands.
"My captain Dani, he's unbelievable, he helps everyone. I think this feeling, he comes to the group and the feeling goes up. He's unbelievable, I don't have words for him," Brazilian goalscorer Matheus Cunha told reporters.
"You know the difference in age is a little bit (big). I'm like a little boy when I saw Barcelona, the Brazil national team, and now we were together, we take one gold medal for Brazil."
Brazil became the fifth country to win back-to-back Olympic golds, after Britain (1908, 1912), Uruguay (1924, 1928), Hungary (1964, 1968) and Argentina (2004, 2008).
For Spain, it was a disappointing end to the tournament, despite some flashes of brilliance produced by their youthful squad, but defender Eric Garcia was not overly disappointed.
"At the end, we must be proud of what we have done. Obviously, we would have liked to get the gold but Brazil took it. We need to be proud of getting this medal, not everyone can do it," he told reporters.
Asked if he intended to play for as long as Alves, the 20-year-old Garcia laughed.
"At his level it's difficult, it was like he was 20 years old!" said the new Barcelona recruit.