Firefighters gained the upper hand Friday on a wildfire that has raged on the western edge of Yosemite National Park all week, prompting authorities to lift all evacuations.

Stepped-up land and air attacks and cooler weather allowed crews to contain an estimated 58 percent of the blaze, up from 34 percent a day earlier. Firefighters' gains also removed threats that flames would make a run on the famed Merced Grove of giant sequoias.

The fire started Saturday in the community of Old El Portal near the park's Highway 140 entrance station. It moved through dense grassland and pine forest in the park's foothills north toward Highway 120, leading to evacuations of both Old El Portal and the nearby town of Foresta.

Three years of below-average rainfall and high temperatures hastened the fire's spread.

Residents of Old El Portal returned home Tuesday, and Foresta residents were allowed back at 3 p.m. Friday. Two homes in the roughly 60-home hilltop community were lost to the blaze.