By Alex Dobuzinskis

LOS ANGELES (Reuters) - 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.

But with the fire 73 percent contained, many residents were allowed to return home, Lopez said.

Overnight, firefighters built strong containment lines near Wrightwood, which allowed residents of that ski resort town to repopulate the area on Saturday, he said.

Residents of 7,000 other homes in the Cajon Pass area were still potentially in the path of the fire, which is burning in heavy brush, and they remained under evacuation orders, Lopez said.

"We feel confident we can keep continuing this aggressive attack," he said in a telephone interview.

Nearly 2,700 firefighters and crew were battling the wildfire, their efforts amplified by more than two dozen water-dropping airplanes and helicopters, according to tracking website InciWeb.gov.

Less than 300 miles (483 km) to the northwest, a week-old blaze called the Chimney Fire threatened the historic Hearst Castle, the former mansion of the late newspaper tycoon William Randolph Hearst, in San Simeon.

Fire information officer Ron Oatman could not immediately say how close the blaze was to Hearst Castle, but he said the main body of flames was moving away from the landmark.

Officials suspended tours of Hearst Castle due to poor air quality, according to a message on Twitter from the California Department of Parks and Recreation.

"It hasn't reached the point that we would call for evacuations" of staff members, Oatman said.

The Chimney Fire had burned nearly 20,000 acres (8,094 hectares) and 46 structures and firefighters have built containment lines around 35 percent of it, officials said.

The causes of both blazes were under investigation.

Nearly 30 major blazes have burned some 530 square miles (1,373 square kms) in eight Western states this week, as prolonged drought and unusually hot weather have intensified wildfire season, the National Interagency Fire Center in Boise, Idaho, said.

(Additional reporting by Letitia Stein; Editing by Grant McCool and Dan Grebler)