Oshie poked in his own rebound at 10:40, which was one of four third-period goals for the Capitals. Washington moved two points ahead of Pittsburgh in the division.
"We needed a win," said Capitals forward Carl Hagelin, who scored two goals including the 100th of his NHL career. "I think it was a gutsy effort. Showed a lot of character there in the third."
WATCH: [All Penguins vs. Capitals highlights]
Jakub Vrana and Tom Wilson scored, and Braden Holtby made 33 saves for the Capitals (38-18-6), who had lost four straight (0-3-1).
"The only way to work through it was to go out there and get it done," Wilson said. "It wasn't an easy game. There were ups and downs. That's a character win. It's one win. We're going to learn from it, it was great for the team, but we've got to keep going here."
Patric Hornqvist, Sidney Crosby and Evgeni Malkin scored for Pittsburgh (37-18-6), which has lost three straight games. Matt Murray made 18 saves.
"I thought we played real well," said Penguins coach Mike Sullivan, whose team has been outscored 14-5 in its previous three games. "It was one of our better games in a while. I thought we had a lot of really good moments in the game."
Malkin tied the game 3-3 at 8:50 of the third when he eluded defenseman John Carlson on the rush and slid the puck past Holtby.