The Kiwis - who host the British & Irish Lions in 2017 - dominated possession and territory for large parts but failed to make that dominance count and it was only a dramatic final stand on their try line in the closing minutes that preserved victory.
And Hansen was full of praise for the way his side clung on, even if there was much to work on in the rest of their performance.
"The character of the side has been tested a few times over the last couple of years and they keep coming up with an A-plus pass mark," said Hansen.
"They put themselves under pressure at times, making poor decisions with our kicking and allowing the Boks to attack us from unstable platforms but we showed a lot of courage to keep them out.
"When you get really tough Test matches you see the true character of people.
"You talk about Test matches being arm wrestles, it was only right at the end that we won it."
In the second game in the Rugby Championship Australia clung on to a 32-25 victory over Argentina on the Gold Coast.
Skipper Michael Hooper crossed twice for the Wallabies while Peter Betham was also on the scoresheet but the Pumas also scored three times and were desperately close to a fourth try and would have earned them a draw before the final whistle was blown.