I was leading my horse up a trail when he started acting up; stopping, pulling, and rearing. I was hot, thirsty, pissed and in no mood for silly games. As I was trying to calm him down, he suddenly charged past me, knocking me flat and heading up the trail. I was recovering, when I heard a thump near me, looked over, and saw a mountain lion crouched and ready to take the next leap right on me. He was about 10' away.
Time froze, my mind went blank, and all I could think of was the rifle in the scabbard on my horse's saddle... that was rapidly disappearing up the trail. I started to get my legs under me, and he snarled, and started to gather himself for a leap.
Without thinking about it, I grabbed a rock and nailed him right between the eyes. He snarled again, and I nailed him with another one. And another. As fast and as hard as I could throw them while on my ass. I hit him on the nose with a 4th rock and he took off up the trail, veering left up the mountain. I threw a couple more as he scrambled up the hill and then he was out of sight... I could hear him moving off so I picked myself up and started moving up the trail after my horse.
About 30 minutes later, I found the horse tangled up in some brush. I got him free and then suddenly started shaking uncontrollably. I couldn't stop for at least another half-hour.
I've been in the mountains many, many times, and that's the only time I've ever really been in serious danger. I've seen bears, mountain lions, had a lynx prowling my camp, been in a major thunderstorm with lightning strikes all around me and no place to hide, winter camped in a surprise storm, etc. But that encounter with a mountain lion was the one that was really dangerous. Turned out ok, as you say, but only because of luck.