John Carlson scored the tiebreaking goal with 4:59 left in the third period, and Alex Ovechkin scored his NHL-leading 44th goal for the Capitals (42-24-7), who lead the Pittsburgh Penguins by four points in the division.
"These are big points now," Carlson said. "Everyone can see how tight the race is and everyone is jockeying for position. You have to collect them when you can. And we had a good game tonight, so that's the most positive."
WATCH: [All Stars vs. Capitals highlights]
Tyler Seguin, Jamie Benn and Alexander Radulov scored for the Stars (38-28-8), who lost their sixth game in a row completing a winless road trip (0-4-2). Dallas remained two points behind the Anaheim Ducks for the second wild card into the Stanley Cup playoffs from the Western Conference having played one more game.
"The road trip from hell's over and we go home," Seguin said. "Nothing you can really do now. Got to get home, got to get points. We're playing some good teams, but we've got to find a way here."
Carlson's goal made it 4-3 at 15:01, a one-timer from the top of the right face-off circle. He and Stars defenseman John Klingberg had two points each and are tied for the NHL lead for points by a defenseman (61).
The Stars took a 1-0 lead on Seguin's power-play goal at 16:04 of the first period.
T.J. Oshie tied the game 1-1 at 4:07 of the second period after a tap pass from Lars Eller. Matt Niskanen gave the Capitals a 2-1 lead at 5:32 when his wrist shot from the blue line beat Kari Lehtonen. The play was reviewed to determine if the puck deflected off a high stick.