A blaze burning in foothills west of Yosemite National Park destroyed dozens of structures and forced thousands to flee Gold Rush-era towns in California before fire crews were able to stop it from reaching a historic community near the Sierra Nevada.

As of Thursday, the Detwiler fire has scorched 70,596 acres — or 109 square miles — and destroyed 99 structures, including 50 homes, the California Department of Forestry and Fire Protection said. The blaze continues to threaten about 1,500 more homes and other buildings.

The flames are near Highway 49, a historical route winding through Sierra Nevada foothills dotted with little towns that drew gold miners to California in the 1800s.

More than 3,100 firefighters are battling the 5-day-old blaze, Cal Fire said.

The fire is 10 percent contained, and has forced almost 5,000 people from homes in and around half a dozen small communities, officials said.

Statewide, about 6,000 firefighters are battling 17 wildfires. Of them, 2,200 firefighters, some of whom are from San Francisco, San Mateo and Palo Alto, are working to extinguish the Detwiler Fire. Christie Smith reports.

Heavy smoke hung in the air over Mariposa, a town of 2,000 people with century-old wooden buildings, including what's touted as the oldest active courthouse west of the Rocky Mountains.

The fire got within a half-mile of Mariposa but crews have been able to keep it out of the town, fire spokesman Jason Motta

"Most of the town of Mariposa has not been affected by anything other than the smoke," Motta said.

At its closest, the blaze was still about 35 miles from the boundary of Yosemite, where campgrounds remain open, park spokesman Scott Gediman said.

The fire closed one of several roads into the park during its busy summer season, and rangers warned visitors with respiratory problems to be mindful of the smoky haze over the park's landmark Half Dome rock face, Gediman said.

Yosemite does not appear at risk from the fire, which was moving south, away from the park, fire spokesman Jordan Motta said.

Tony Munoz, 63, and his wife, Edna Munoz, 59, were ordered out of their home outside Mariposa on Tuesday. They grabbed clothes, medicine and their three dogs and a cat before fleeing.

Driving out on narrow, congested roads, "you couldn't even see the sun" in the ash-filled sky, said Tony Munoz, a school custodian.

Downtown Mariposa was empty except for firefighters and other emergency workers. Fierce flames were visible on slopes about a mile away.

Record rain and snowfall in the mountains this winter abruptly ended California's five-year drought. But that has increased the challenge for crews battling flames feeding on dense vegetation.

"There's ample fuel and steep terrain," Cal Fire spokeswoman DeeDee Garcia said. "It makes firefighting difficult."

Statewide, about 6,000 firefighters were battling 17 wildfires, including about 2,200 at the fire near Yosemite. Of them, some are from San Francisco, San Mateo and Palo Alto.

Gov. Jerry Brown has declared an emergency Tuesday, bolstering the state's resources to battle the fire.

Associated Press writer Kristin J. Bender contributed to this report.