More than 180,000 people in northern California have been told to evacuate after two overflow channels at the US's tallest dam were found to be damaged.
The 770ft (230m) high Oroville Dam is not itself at risk of collapsing, but its emergency spillway was close to caving in, officials said.
Officials feared the damaged spillway could release large amounts of floodwater downstream.
The excess water has now stopped flowing.
However, late on Sunday, Butte County Sheriff Kory Honea said the evacuation orders remained in place.
Water levels in the reservoir have risen following heavy rain and snow after years of severe drought.
It is the first time that Lake Oroville, which lies 65 miles (105km) north of Sacramento, has experienced such an emergency in the dam's near 50-year history
The evacuation order came after water levels in the reservoir rose sharply last week. The dam's main spillway, also known as an overflow channel, was found to be damaged.
As the water rose even higher, the dam's emergency spillway was activated for the first time since its completion in 1968.
'Evacuees welcome at my home'
However, this secondary slipway was also found to be damaged.
In a statement posted on social media on Sunday afternoon, Mr Honea ordered residents to evacuate, repeating three times that it was "NOT a drill".
The California Department of Water Resources warned that the emergency spillway next to the dam was "predicted to fail".
There was gridlock on roads heading out of Oroville, a town of 16,000 people, with some evacuees complaining that they should have been given more warning.
One evacuee, Nancy Borsdorf, told AP she "panicked" and was in such a hurry to leave she "grabbed some wet laundry. Can you believe that?"
Several hours after the evacuation order, the emergency spillway was still standing.
However, California Fire Incident commander Kevin Lawson said officials stood by the decision to evacuate residents, rather than risk thousands of lives.
He said if the situation was not dealt with they were looking at "a 30ft wall of water coming out of the lake".
The California Department of Water Resources said it was releasing as much as 100,000 cubic feet (2,830 cubic metres) of water per second from the main spillway to try to lower the lake's level and relieve the pressure.
Helicopters were dispatched to drop boulders to try to block the eroded area in the spillway.
Butte County's official Twitter feed shared news of emergency shelters, and reported that many hotels were fully booked in the wider area.
One local resident, Javier Santiago, moved his family to the dam's visitor centre, which sits at the top of the structure and away from the flow of water.
"We're going to sleep in the car," he told Reuters news agency, adding that he had packed blankets, pillows and a little food for himself, his wife and their two children.
Gurtej Singh, a manager at a Sikh centre in Sacramento, said the local mayor's office contacted his organisation to ask if they would host evacuees.
"We, in turn, put a call out to members of our community to see if they could provide food, bedding etc, so that around 50 people could stay at our centre," he told the BBC.
Sheriff Honea said that the evacuation was declared to avoid a "worst-case scenario".
He added that no decision had been made as to when people would be allowed back into their homes, as the authorities were still assessing the risks.
Doug Carlson, from the California Department of Water Resources, told the BBC that the situation was looking positive, as the lake level had dropped during the night after the emergency measures were taken.
"That's very good news for the people downstream," he said.
After a long period of drought, California has been experiencing heavy rain and increased snowfall, which has led to flooding and mudslides.
On Friday, California Governor Jerry Brown asked the Federal Emergency Management Agency to declare a major disaster.