Ovechkin's spectacular play made it 3-1 with 11:33 left.
He pushed the puck through Henrik Tallinder's legs just inside the blue line, got around him and fired a shot past goalie Patrick Lalime while falling.
"He was mad, and he was going to make up for it," Washington coach Bruce Boudreau said. "They were checking him, and he was losing the puck, but he was just determined. It was like, 'They took one away from me, and they're not going to take another one away."
The sellout crowd of 18,277 broke into loud chants of "M-V-P!, M-V-P!" for Ovechkin, the NHL's reigning Most Valuable Player.
"It was a pretty cool goal," Ovechkin said. "I just made some moves. You always want to do some crazy things. It was a great goal, and I'm happy it happened to me."
Defenseman Bryan Helmer had the only assist on the goal, pushing the puck forward to Ovechkin, who did the rest.
"That's why he's the best in the league," Helmer said. "He never gives up on the puck, and the next thing you know it's in the back of the net. It's amazing what he can do."
Ovechkin appeared to give the Capitals a 2-0 lead late in the second, but a goalie interference call against teammate Brooks Laich negated that and lit the MVP's fire.
The Capitals never trailed because Theodore turned in another strong effort. He's been inconsistent but gave up just one goal in the final two periods against the Rangers Tuesday when Boudreau put him back in after pulling him in the first. That carried over into this game.
"The last two periods was what I was trying to remember coming into tonight's game," Theodore said. "I was just looking at the last two periods thinking I have to do the same thing, and that's pretty much what I did."
Washington improved to an Eastern Conference-best 14-1-1 at home. The injury-depleted Capitals are 8-10-2 on the road.
Washington opened the scoring on Kozlov's hard shot from near the right boards with 2:14 left in the second period.
Ovechkin appeared to score 1:09 later, but the goalie interference call changed that. The Capitals rebounded from that 1:58 into the third period when Gordon redirected Milan Jurcina's shot past Lalime.
Buffalo made it 2-1 on Vanek's power-play goal at 6:13 of the third period. Vanek had crawled off the ice after getting hit by an Ovechkin shot in the second period.
Ovechkin gave the Capitals a two-goal edge with his big play, and Afinogenov completed the scoring with 1:49 left.
"They capitalized on our mistakes, the Ovechkin goal especially," Buffalo coach Lindy Ruff said. "We won the battle of special teams, but we didn't win the battle at even strength."
Washington RW Chris Clark returned after missing 14 games because of a forearm injury. ... Helmer had two assists and earned the game's first star ... Afinogenov's goal hit his feet and deflected into the net while he was jumping to get out of the way of Toni Lydman's shot.
Copyright by STATS LLC and The Associated Press
Arena: Verizon Center Location: Washington, District of Columbia
Referees: Paul Devorski, Wes McCauley Linesmen: Derek Amell, Tim Nowak
Attendance: 18,277 (99.3% full)
Team Stat Comparison
Power Play Goals
Power Play Opportunities
Shots on Goal
No scoring this period
Viktor Kozlov (9)
Assists: Nicklas Backstrom, Bryan Helmer
Boyd Gordon (3)
Assist: Milan Jurcina
Thomas Vanek (25)
(Power Play) Assists: Drew Stafford, Jaroslav Spacek
Alex Ovechkin (23)
Assist: Bryan Helmer
Maxim Afinogenov (2)
Assists: Toni Lydman, Ales Kotalik