A man from Haines Junction, Yukon, is crediting a smart dog, a sturdy tree and a can of bear spray with saving him from a recent grizzly bear attack.

Bob Hayes said he came across the grizzly sow on Aug. 3, while running with his dog on a recreational trail just outside Haines Junction.

"When I saw her, she was already charging me," Hayes told CBC News in an interview Friday afternoon.

"I saw this immense instant attack coming at me, and I kind of exclaimed something that … probably most people would exclaim," he added with a chuckle.

"The funny part is, I think I actually kind of jumped up with both of my feet, like in a cartoon. I mean, I was just totally just awestruck and in total panic."

Hayes said his dog Charlie helped distract the bear long enough for him to climb up a nearby spruce tree.

Even so, the bear managed to bite Hayes on the ankle as he scrambled up the tree. It wasn't until he was safely up the spruce that Hayes remembered he was carrying a can of bear spray.

He used the spray to convince to bear to leave the area.

"The effect was enormous on the bear. The bear was maybe one or two metres from the end of it, and it just got a full face of this bear spray," Hayes recalled.

"And it … immediately just bolted and in a raging, raging roar just began running through the forest and growling and roaring and smashing trees."

Hayes estimated that the bear ran around in loops for another 10 to 15 minutes. During that time, he said he also heard what he thought was a bear cub.

The sow eventually disappeared: "It seemed like endless waiting to see if I could hear her again, and I didn't after … five to 10 minutes I stayed in the tree," Hayes said.

"You can imagine how quiet I was as I was climbing down this tree."

Aside from some scrapes from climbing up the tree, Hayes said he was not injured, and his dog Charlie was fine.

Hayes said he wants to share his experience as a lesson to others, emphasizing the importance of keeping bear spray handy.