In this post over in this thread, @Broomstick said the following:
I have guns, too, but would not use them in self-defense against a bear. The vast majority of firearms are simply not that effective against an attacking or charging bear. The way to safely take on a bear with a firearm is at a distance with a high-powered rifle.
A bear attack, on the other hand, is by definition at a much closer range such that a rifle is difficult or impossible to use. And the vast majority of handguns are far too underpowered to do much against a bear. And that’s assuming you are actually able to get an aimed shot off and hit the bear before it’s in your face and mauling you to death. Not to mention the fact that if you do actually hit the bear, you are now dealing with an injured and likely more aggressive bear. You are almost certainly not going to be able to take it down before it kills or seriously injures you.
Bear spray, on the other hand, is reportedly far more effective. It produces a cloud of irritating spray that is far more likely to repel a bear and stop an attack.
There was a study from BYU that compared three options in fending off an aggressive bear: doing nothing, using a firearm, and utilizing bear spray, and they concluded that bear spray was by far the most effective. More specifically, the people who used a firearm against an aggressive bear suffered the same injury/fatality rate as those who did not. (Note that most of the bears involved in the study were brown bears, aka grizzly bears, which are typically much more aggressive than the smaller black bears.)
A related study by the same researcher found that bear spray effectively halted aggressive bear encounters in 92 percent of cases.
The National Park Service agrees with this advice.
For what it’s worth, I took my own advice when I took a trip to Alaska last summer and went on four hikes in bear country on the Kenai peninsula. (There were warnings about bears at every trailhead.) I and my hiking partner each carried bear spray at all times, and not in our packs, but in holsters on our hips. (We also took all of the other recommended precautions, like making a lot of noise, not hiking alone, and not bringing a dog along.)