A massive wildfire near the world-famous Yosemite National Park in California is continuing to spread but firefighters claim they are gaining ground after a 10-day battle.

Fire officials said about 3,700 firefighters on the ground were making progress against the blaze known as Rim Fire, which has engulfed nearly 252 square miles (161,280 acres) since August 17.

"We're not there yet, but we're starting to get a little bit of a handle on this thing," said Lee Bentley, fire spokesman for the US Forest Service.

"It's been a real tiger. He's been going around trying to bite its own tail, and it won't let go but we'll get there."

The fire is now 20% contained and fire officials are confident they will manage to keep flames away from some of San Francisco's key water reservoirs and power plants.

Earlier this week authorities, activated a $4.6bn (£2.9bn) gravity-operated pipeline system to quickly move to water stored in the Hetch Hetchy Reservoir to other basins closer to San Francisco.

Flames had reached the reservoir's edges and ashes threatened to pollute water that feeds 2.6 million people in the San Francisco Bay area.

"We're taking advantage that the water we're receiving is still of good quality," said Harlan Kelly Jr., general manager of the city's Public Utilities Commission. "We're bringing down as much water as possible and replenishing all of the local reservoirs."

Meanwhile hydroelectric generators that provide much of the Californian city's electricity were shut down because of the approaching flames.

San Francisco is buying replacement power from other sources.

About 4,500 structures are currently threatened by the advancing fire while 23 have already been destroyed.