The Brumbies had been kept scoreless in the second half until replacement hooker Connal McInerney crashed over from an attacking lineout in the 75th-minute.
Hansen missed the sideline conversion but then calmly slotted the winning penalty from about 40 metres deep into extra time.
Starting hooker Folau Fainga'a had scored two first-half tries for the home side, who were lucky to win the match after the Reds had dominated the second half.
The Brumbies are now the only unbeaten side in the Australian domestic competition, having won four games and moved to 18 points, seven ahead of the Reds.
The Reds had not won in Canberra since 2014 and struggled to impose themselves in the first half as Fainga'a gave his side a 14-0 lead.
The Reds got on the scoreboard through a James O'Connor penalty but were unlucky not to have been closer when they had a try by Jordan Petaia ruled out following a television review of the tackle that sparked the 80-metre movement.
Referee Nic Berry said Lukhan Salakaia-Loto's tackle on Brumbies winger Tom Wright, which caused the turnover in the Reds' 22-metre area, had been high and he overturned the try and instead issued a penalty to the Brumbies.
Flyhalf Bayley Kuenzle missed the attempt and his side went to halftime with a 14-3 lead.
The Reds, however, raced out to a 20-14 lead 10 minutes into the second half with tries to loose forwards Harry Wilson and Angus Scott-Young and a penalty to O'Connor.
While the Reds dominated the rest of the half, the Brumbies engineered a tight finish when McInerney was driven over.
Hansen missed the sideline conversion that would have given his side the lead but then held his nerve to ensure victory. (Reporting by Greg Stutchbury in Wellington; Editing by Ken Ferris)