Barrett sealed a see-sawing contest from close range after the New Zealand side went through 18 phases before Butch James was crucially whistled for being in an offside position.
Only minutes earlier James looked like being the match-winner when he stormed over and the impressive Elton Jantjes converted.
But the Hurricanes kept their cool to methodically work their way forward before their 20-year-old fly-half landed the most important of his five penalties on the night.
It was the visitors' first win of the new Super 15 season although they made hard work of it after twice looking like running away with the match in each half.
The Lions were first to cross when Jaco Taute went over after nine minutes but Barrett's kicking had his side 9-8 ahead on the half-hour.
With the Lions' pack threat also nullified, after injuries forced non-contested scrums, the Hurricanes looked like cashing in when Andre Taylor finished a fluid backline move in the corner to make it 14-8 at the break.
The Lions had looked short of ideas before the break but Jantjes pulled them back into the contest after the restart.
His bursting run created a break on 55 minutes that ended with Jaco van der Merwe flopping over.
Jantjes converted to make it 18-17 but immediately the hosts gave up a pair of tries.
The immediate response came through hooker Coles, who surprised his rivals with his pace to get to the loose ball after Conrad Smith had twice intelligently kicked off the ground.
A minute later World Cup winner Jane finished another good move when his searing speed carried him to a kick behind before the Lions defence could cover.
The game looked over but Jantjes again got to work.
First the fly-half kicked over a penalty, having taken over the duties from Taute, and was then at the heart of the move that ended with James bullocking over on 71 minutes.
Jantjes had effectively turned the game his side's way but there was one twist left, thanks to a patient Hurricanes drive, which left his young counterpart Barrett to claim the match-winning moment.