Firefighters had a Southern California wildfire mostly surrounded on Saturday, allowing thousands of evacuated residents to return to their houses as another fire further north moved perilously close to the historic Hearst Castle, officials said.

The Blue Cut fire, named after a narrow gorge where it ignited about 75 miles (120 km) northeast of Los Angeles on Tuesday in an area called the Cajon Pass, has burned more than 37,000 acres (15,000 hectares) and destroyed 105 homes and 213 outbuildings, said fire information officer Mike Lopez.

At its height, the blaze forced authorities to order more than 80,000 residents to evacuate their homes.