Defending champion Chen Yibing of China looked set to retain his Olympic title and led the way through the competition after he competed first and scored an impressive 15.800.
Zanetti was the last man to compete and powered to gold with a score of 15.900, with Italy's Matteo Morandi finishing in bronze medal position.
I'm very happy. I was the last gymnast to compete and I stayed calm and took my moment.Arthur Nabarrete Zanetti
Iordan Iovtchev, the oldest male gymnast competing in his sixth Olympic Games at the age of 39, scored 15.108 to finish in seventh.
'I'm very happy,' Zanetti said. 'I was the last gymnast to compete and I stayed calm and took my moment. It's the very first Olympic medal for Brazil in gymnastics so I'm really happy with this.'