A brave Canadian man miraculously survived a brawl with a cougar — after he punched the big cat to save his dog.

William Gibb, of Alberta, told CBC that the harrowing ordeal unfolded after he and his brother went to meet a friend for coffee at Tim Horton’s and he let his dogs, Sasha and Mongo, out of the car for a bathroom break in a wooded area near the parking lot.

Moments later, Sasha, a Husky, began yelping and Gibb instinctively sprinted toward her.

“She (Sasha) was crying out in pain and distress, so I went running,” Gibb told CBC.

“And I saw something wrapped around her, so I ran up and punched it in the side of the head,” the 31-year-old electrical subcontractor said. “At that point, I realized it was a cougar.”

Gibb kept on swinging at the cougar with his right hand, and attempted to scoop up his trembling dog with his left. The wounded pooch was so alarmed by the cougar attack that she dug her teeth into Gibb’s hand, possibly because she mistook him for the feisty feline.

The cougar eventually set its eyes on Gibb’s other dog, Mongo, an Alaskan Malamute.

“I could see the cougar going for him, so I got between him and the cougar and started swinging and screaming at it, and called for my brother and friend to come give a hand,” Gibb told CBC.

“And then I reached down for the closest, biggest stick that I could find and I ran back into the trees to go fight the cougar,” he continued.

Gibb finally managed to get both Mongo and Sasha safely into his car, and he drove Sasha for medical treatment at Hilltop Veterinary Clinic just one block away.

Officers with the Royal Canadian Mounted Police arrived minutes later and, after consulting fish and wildlife officials, decided to kill the cougar.

Sasha — who suffered bite wounds near her neck and tears on her belly and armpits — was released from the vet Wednesday after getting stitches, reported the Alberta Star.

Gibb walked away with no more than a few claw marks on his arm.

“I wouldn’t recommend everybody wrassle with a cougar, but in this case it worked for the best,” RCMP Sgt. Jack Poitras told CBC.

He warned that pet owners should always use caution when on outings in the wilderness, especially near the mountains.