WASHINGTON — CJ Abrams and Lane Thomas homered, rookie Jake Irvin struck out a career-high nine and the Washington Nationals beat the San Francisco Giants 5-3 on Friday night.

J.D. Davis and Joc Pederson homered for the Giants, who have dropped three in a row since a seven-game winning streak that spanned the All-Star break. San Francisco began play Friday two games behind the NL West-leading Los Angeles Dodgers.

Abrams continued his torrid month, recording his ninth multihit game of July after collecting 13 in his first 81 games. He has thrived since moving into the leadoff spot July 7 and is hitting .415 (17-for-41) in Washington’s last 10 games. He homered off Alex Wood (4-4) with two outs in the second for his ninth of the season. He also doubled to lead off the fifth, chasing Wood.

Abrams stole his 10th base in 11 games later in the fifth and scored on Joey Meneses’ two-out double.

The Baltimore Banner thanks its sponsors. Become one.

“He’s not trying to do too much,” Nationals manager Dave Martinez said. “He’s trying to stay in the middle of the field. He’s trying to get on base for his teammates. I talk a lot about leading off and being that catalyst for eight other guys behind you, and he’s doing that right now.”

The Nationals, who had lost four of five, scored twice in the first. Thomas had a solo shot to center, and Keibert Ruiz added an RBI double. Washington took a 4-3 lead in the fourth on Michael Chavis’ RBI double.

“Their lineup is talented and we saw that when they were at our place [in May] and they were able to get the barrel on a lot of balls,” San Francisco manager Gabe Kapler said. “And there’s a couple guys in their lineup that are having really good years, and they just took advantage of some pitches in the middle of the plate and made us pay for them.”

Irvin (3-5) defeated the Giants for the second time this season. The 26-year-old right-hander worked a career-best 6 2/3 innings and struck out five hitters looking.

Irvin gave up an opposite-field solo home run to Davis in the first and a two-run shot by Pederson that scored LaMonte Wade Jr. and landed in the third deck in right field. He leaned on his changeup more as his night unfolded and induced 13 swings and misses, another career high.

The Baltimore Banner thanks its sponsors. Become one.

“I think it was pretty clear they started to sit on the breaking ball, especially early in counts with the Wade single and the Pederson home run,” Irvin said. “But just kind of have to change up the mojo after that, and I decided throwing change-ups was probably going to be the best way to keep guys off balance.”

Kyle Finnegan worked a 1-2-3 ninth for his 13th save.