Adrian Kempe, Phillip Danault and Vladislav Gavrikov also scored, and Pheonix Copley made 20 saves as the Kings (37-20-8) won their sixth straight game on home ice.
Copley (20-4-2) became the fastest goalie in Kings history to reach 20 wins in a season, doing so in 29 games.
Alex Ovechkin scored a power-play goal and Rasmus Sandin had a goal and an assist for the Capitals (31-28-6), who failed to pick up a third straight win in California. Darcy Kuemper had 37 saves.
Anderson restored the lead at 3-2 for the Kings off the rush with his third goal of the season, which was set up by Quinton Byfield’s fourth assist during a four-game streak.
Kempe chipped in an empty-net goal with 1.8 seconds remaining to seal the Kings’ win.
Oveckhin tied it 2-2 at 2:31 of the third period, burying his trademark one-timer from the left circle during a two-man advantage after Copley had saved two previous attempts. It was his 36th goal of the season and 11th on the power play.
Danault put the Kings up 2-1 with 32 seconds left in the second period, batting down Viktor Arvidsson’s shot to send it tumbling in underneath Kuemper.
Both the Capitals and Kings acquired defensemen in the run-up to the trade deadline, and it was Sandin and Gavrikov who opened the scoring for their new teams.
Sandin was somehow able to beat Copley five-hole with a backhand shot from his knees after whiffing on a possible one-timer from Sonny Milano midway through the second.
Despite being brought in to offer physicality and address an imbalance between left- and right-handed defenders, Gavrikov showed good offensive instincts in crashing the net to put in Kevin Fiala’s rebound to tie it at 1.
Kings forward Zack MacEwen made his team debut after being acquired in a trade from Philadelphia on Friday.