With the victory, the defending World Series champion Nationals won the three-game series and climbed out of last place in the NL East at 8-11.
''We've just got to hang in there,'' manager Dave Martinez said. ''This is a weird season.''
And it comes a year after the Nats notably were 19-31 before taking off on their way to the team's first title.
Washington got the decisive run after Scherzer blew a four-run lead during an up-and-down performance in which he gave up a pair of solo homers to Anthony Santander and a three-run shot to Pedro Severino.
''He made a couple bad pitches but other than that he pitched well,'' Martinez insisted. ''He was good. He kept us in the ballgame. It was nice that we scored (in the eighth) and he was able to get the win.''
With the score 5-all, Juan Soto drew a one-out walk from Travis Lakins (2-1) and took second on a groundout. Kurt Suzuki followed with a two-out grounder to third baseman Rio Ruiz, whose throw bounced past first baseman Renato Nunez, enabling Soto to score.
Scherzer (2-1) gave up five runs and eight hits. It was his 96th game with at least 10 strikeouts, leaving the three-time Cy Young winner one short of Sandy Koufax for fifth place on the career list.
It wasn't his most impressive performance, but Scherzer will take it.
''At the end of the day, we won. That's the most important thing,'' he said.
Tanner Rainey struck out the side in the eighth and Daniel Hudson got three outs for his fourth save.
Orioles starter John Means was pitching for the first time since Aug. 4 after going on bereavement leave and adhering to coronavirus safety protocol. Given the left-hander's lengthy absence prior to the game, Orioles manager Brandon Hyde was asked before the game what to expect.
''We just don't know what we're going to get out of him today,'' Hyde said.
The answer: three runs, four hits and a walk while getting only two outs.
Trea Turner opened with an 11-pitch walk, and Asdrubal Cabrera and Victor Robles hit RBI singles around a sacrifice fly by Carter Kieboom to prompt Means' early exit.
''To come up with three runs when you have your No. 1 guy in there, it's pretty nice,'' Martinez said.
An All-Star as a rookie last year, Means got off to a late start this season because of arm fatigue and has an 10.57 ERA after three outings.
''Physically I'm there, it's just more of a feel thing,'' Means said. ''Give me another outing or two and I'll be ready to go.''
It was 5-1 in the sixth before Severino homered, and Santander knotted the score with a drive far over the right-field scoreboard. Prior to this outing, Scherzer allowed only one home run in four starts.
Despite the loss, Santander won't soon forget the day he homered twice in the game against Scherzer.
''Very happy. I'm trying to beat him, he's trying to beat me,'' Santander said. ''Thankfully, I was fortunate to hit two home runs off of him. He's definitely one of the best of all time.''
Nationals hitting coach Kevin Long and pitcher Anibal Sanchez were ejected in the second inning for arguing over calls by home plate umpire Will Little, who tossed the duo.
Nationals: INF Howie Kendrick was given the day off to rest his sore hamstrings.
Orioles: Reliever Dillon Tate (elbow contusion) is making progress in his bid to return from the 10-day IL after getting hit by a line drive in an intrasquad game in July. He's been throwing to batters at the team's alternate site and is ''getting close'' to being eligible to return, Hyde said.
Nationals: Sanchez (0-3, 9.69) tries to get on track for Washington in the opener of a three-game series in Atlanta on Monday night.
Orioles: The Toronto Blue Jays come to town from their temporary ''home'' in Buffalo to begin a three-game set Monday night.
More AP MLB: https://apnews.com/MLB and https://twitter.com/AP-Sports
Copyright 2020 STATS LLC and Associated Press. Any commercial use or distribution without the express written consent of STATS LLC and Associated Press is strictly prohibited.