An uncontrolled wildfire in Southern California grew explosively on Saturday, quadrupling in size to over 17,000 acres by Sunday morning and leading to mandatory evacuation orders for over 5,000 people.

As firefighters struggle to contain the blaze in the foothills of the San Bernardino Mountains, they are dealing with a dangerous heat wave that is expected to affect Southern California and part of the Southwest until at least Monday.

The heat wave is also raising the risk of more fires. On Sunday, the region stretching from the Pacific Coast to the mountains northwest of Los Angeles, including parts of Santa Barbara County and Ventura County, was under a red flag warning. That is the highest National Weather Service alert for conditions that may result in extreme fire behavior.

The San Bernardino blaze, known as the Line Fire, started on Thursday in the city of Highland, east of Los Angeles, according to San Bernardino County and the California Department of Forestry and Fire Protection.

On Saturday, fueled by soaring temperatures of over 100 degrees Fahrenheit and “critically dry” vegetation, the fire spread rapidly toward the San Bernardino Mountains and grew from about 3,800 acres in the morning to 17,237 acres by nighttime, according to Cal Fire and the San Bernardino County Sheriff’s Department.

As of Sunday morning, it was 0 percent contained and threatened more than 8,000 structures, according to Cal Fire. The cause was under investigation.

More than 5,000 people in San Bernardino County were under mandatory evacuation orders on Saturday night, said Brent Pascua, a Cal Fire spokesman. The orders included parts of Highland and Running Springs, a community in the San Bernardino Mountains, the county authorities said.

“We saw really extreme fire activity and a really quick-moving fire” on Saturday, Mr. Pascua said. “We’re not going to get much help as far as the weather goes.”

San Bernardino County and parts of Riverside County were under excessive heat warnings until Monday evening, the most serious heat alert. The Weather Service warned that daytime temperatures could reach 102 to 110 degrees, while the lowest night temperatures would fall only to the mid- to upper 70s.

About 500 firefighters were trying to contain the blaze on Saturday, but steep terrain and lack of access impaired their ability to reach some areas, Cal Fire said.