YOSEMITE NATIONAL PARK — It wasn’t that long ago that a trip to see Yosemite’s spectacular granite cliffs and splendid waterfalls was a descent into bear mayhem.

In 1997, black bears broke into more than 600 cars in the park, searching for human food as they tore open the doors of Toyotas and Hondas, smashing minivan windows with their paws. The ursine marauders wandered into tents, overturned garbage cans and, on rare occasions, injured tourists.

“You’d drive your car to the park and then it got destroyed because you left a candy bar in the door,” said Mike Tollefson, a former Yosemite superintendent.

But today, in one of Yosemite’s most remarkable wildlife success stories, the bears are behaving better. Reports of bears damaging property or injuring people in the park have fallen 92 percent — from 1,584 in 1998 to 120 last year. And the number of bears that park officials have had to kill because they pose safety problems has fallen from about 10 a year in the 1990s to one or two a year now.

Biologists say the long, slow turnaround came from an unlikely strategy — training the bears but, more importantly, training people.

“The numbers are down, and that’s awesome,” said Ryan Leahy, a Yosemite wildlife biologist and bear expert. “More and more people are doing what they are supposed to do. But it only takes one slipup to cost a bear’s life. Each person can have a huge impact.”

Yosemite has between 300 and 500 black bears. Thousands more live in the rest of California and other Western states.

There has never been a recorded incident of a black bear killing a person in Yosemite, or anywhere in California.

Grizzly bears, their larger and fiercer cousins, do occasionally kill people. But grizzlies, despite being immortalized on California’s state flag, have been gone from the Golden State since the last one was shot in Tulare County in 1922. They are now found in Canada, Alaska, Montana, Idaho and Wyoming.

In Yosemite, the relationship between people and bears has changed dramatically. From 1923 to 1971, rangers regularly left food out for bears so tourists could take pictures. Park visitors hand-fed bears until the 1930s and, until 1972, there were open garbage dumps that provided bears massive amounts of easy food — and made them seem more like circus attractions than wild animals.

Black bears became a growing problem in Yosemite during the 1980s and 1990s, when the number of park visitors increased to 4 million a year.

“Have you ever been in a vehicle or house that a bear has been in it? It’s not pretty,” Tollefson said. “They just don’t poop in the woods. The big ones weigh 400 pounds. They can run as fast as a horse, and they’re strong.”

The animals made national news for their brazen behavior, and park officials launched a new campaign that they say helped solve the problem in four ways.

First, using a 1999 grant from Congress for $500,000 a year, they expanded the number of rangers, biologists and volunteers working on bear issues from two to about 20 now.

The park required all campers to store food in steel, bear-proof lockers. Today, there are roughly 4,000 such lockers around Yosemite — from Curry Village to White Wolf to the Tuolumne Meadows camping areas. The money to install about half of those lockers came from the Yosemite Conservancy, a San Francisco nonprofit group that has spent $2.1 million to solve the park’s bear issues over the past quarter-century.

Next, the park launched a massive public education campaign. Campers are now required to sign forms saying they understand it is illegal to feed bears or store food — even toothpaste, deodorant or other scented toiletries — overnight in vehicles. Videos touting bear-safe camping tips play in visitor’s centers. Rangers patrol campsites every night, giving warnings and issuing citations of $125 for repeated flouting of the bear rules.

“The rangers are aggressive with folks,” said Tollefson, now president of the Yosemite Conservancy.

Third, the park in 2007 required everyone going on overnight backpacking trips in Yosemite’s remote wilderness areas to rent a bear canister, an impenetrable cylinder in which to store food. “People were hanging food on ropes in trees,” Tollefson said, “but mother bears taught their cubs how to climb up and get it.”

Finally, park officials went high-tech. They began trapping problem bears, fitting them with radio collars and monitoring their whereabouts. A new $70,000 program this year is introducing GPS collars, which are even more precise.

When a bear comes near a campsite, wildlife biologists will chase it, yelling and occasionally shooting a small bean bag or clear ball filled with mineral oil from a paintball gun. The idea, called “negative conditioning,” is designed to teach bears that coming near humans and trying to eat human food instead of their usual diet of acorns, grass and berries has unpleasant consequences.

“We are trying to teach them that people should be feared,” Leahy said. “We aren’t going to chase a bear foraging in a meadow, but if it’s in a parking lot, we’re going to show the bear, ‘Hey, we need to keep you out of there.'”

The upshot: Bears in Yosemite are becoming wild again as older ones accustomed to eating human food die off and younger ones are finding human food harder to get.

A study in March using isotopes to analyze bear fur and bones found a 63 percent drop in the proportion of human food that black bears are consuming now, compared with the 1970s and 1980s.

“What we found was that the diets of bears changed dramatically after 1999,” said Jack Hopkins, lead author of the study and a research fellow at UC Santa Cruz.

Damage from bears in the park has fallen an astounding 99 percent — from $659,569 in 1998 to $7,508 last year. Seven people were injured by bears in 1998, and nobody has been injured in the past two years.

Longtime campers say they are noticing a difference.

“You get hit in the side of the head with the education coming, going and the whole time you are there,” said Steve Johnson, a retired civil engineer from Walnut Creek.

Johnson has seen dozens of bears in the park since he first went backpacking as a 12-year-old in 1971 with a San Jose YMCA group. In 1999, when he was at Glen Aulin backpacking camp with his two sons, a bear wandered around the campsite, left and then suddenly returned. Johnson had to chase it away.

“Bears that get too habitualized to people lose their fear of people,” Johnson said. “Although a bear has never killed a person in Yosemite, they certainly have the ability if they wanted to. The less interaction between the two, the better for everybody.”

Paul Rogers covers resources and environmental issues. Contact him at 408-920-5045. Follow him at Twitter.com/PaulRogersSJMN