Hamlin, who earned the pole for the non-points exhibition race earlier Saturday at the Los Angeles Memorial Coliseum, fell back into the field during the race but rallied back to the front with 10 laps remaining.
He then held off Kyle Busch in a two-lap overtime as the those behind Hamlin bumped and banged off each other battling for position.
“A lot of it was what happened in front of me with (Ty Gibbs) and (Joey Logano). You just never know what was going to happen there,” Hamlin said. “But I got a really good run off of Turn 2 and got position and was able to hang on from there.
“It’s so chaotic with the restarts with everyone just bumping and banging but it feels good to win here in L.A.”
Hamlin called the win a “big momentum boost.”
“It doesn’t do much more than that,” he said. “I clean off all the trophies every January 1 and now we get to add one pretty quick.”
As the crowd on hand started showering Hamlin with boos, he retorted, “You know I beat your favorite driver again, right?”
The win was an impromptu one for Hamlin. Saturday night’s race was originally scheduled for Sunday night but impending severe weather that could last several days prompted NASCAR to attempt to run the event a day early in order to get it in.
A multiple-day delay, combined with dangerous flooding conditions predicted for the area, would likely have caused NASCAR to eventually cancel the race.
The last restart was set up after Ty Gibbs lost the lead on the previous restart to Hamlin and got spun around in Turn 4 with just one of the originally scheduled laps remaining to send the race into overtime.
Logano started the second segment in the lead and had to work hard to fend off repeated challenges for the lead from Larson and Gibbs in the opening laps.
Gibbs eventually powered out to the lead on a restart on lap 78 while Logano and Larson battled for second.
With 50 laps remaining, Gibbs had moved out to a more than 2.5-second advantage over Logano as Busch had moved into third.
Hamlin, who led the race early but dropped back to seventh at one point, moved into third and back into contention with 30 laps to go.