WASHINGTON — Max Scherzer allowed two hits over eight innings and Bryce Harper’s two-run double helped the Washington Nationals avoid a four-game home-and-home sweep with a 4-0 victory over the Baltimore Orioles on Thursday night.

Scherzer (14-7) struck out 10 and did not walk a batter. He retired 12 straight after Adam Jones’s fourth-inning double and 21 of 22 before Mark Trumbo’s leadoff single in the eighth.

Jayson Werth’s solo home run staked Washington to a 1-0 lead. Daniel Murphy’s RBI double in the eighth came before Harper’s second hit helped the Nationals pull away.

The Nationals had lost four straight including three in a row to the Orioles, who won twice in Baltimore before the teams shifted to Washington.

Ubaldo Jimenez (5-11) allowed one run and five hits over six innings.