The NL East-leading Nationals improved to 82-52. The club moved from Montreal to Washington for the 2005 season and went 81-81 that year. In 2008 and 2009, the team lost a combined 205 games, then finished 80-81 in 2011.
The Nationals' win allowed them to hold their 6 1/2-game division lead over Atlanta.
Detwiler (9-6) struck out three and walked three, allowing only one runner to reach third.
Jeff Samardzija (8-13) gave up a long home run to LaRoche to lead off the second.
Tyler Clippard allowed two hits and a two-out RBI single to Welington Castillo in the ninth. Clippard threw the ball away for an error and allowed pinch-runner Tony Campana advance to second before striking out Josh Vitters for his 30th save in 33 opportunities.
Samardzija gave up seven hits in seven innings. He walked one and struck out eight.
PHILLIES 4, REDS 2
CINCINNATI (AP) — Jimmy Rollins hit a three-run homer off Johnny Cueto during a cloudburst that sent fans scurrying for cover, leading Philadelphia over Cincinnati.
John Mayberry Jr. added a solo homer off Cueto (17-7), who failed in his attempt to become the majors' first 18-game winner. Cueto also lost a day game for the first time this season — he'd been 11-0 in 13 afternoon starts.
Rookie right-hander Tyler Cloyd (1-1) got his first major league hit and win. He singled ahead of Rollins' homer to extend the inning. The 25-year-old gave up four hits, including Jay Bruce's 30th homer, and struck out nine in seven innings.
GIANTS 9, DIAMONDBACKS 8
SAN FRANCISCO (AP) — Marco Scutaro hit an RBI single in the 10th inning after Buster Posey's tying double in the ninth as San Francisco rallied to beat Arizona.
Brandon Crawford beat out a single to short leading off the 10th and moved to second when Brett Pill dropped a sacrifice bunt. Angel Pagan grounded out to first to advance Crawford.
Scutaro sent the final fastball from Bryan Shaw (1-5) past diving third baseman Chris Johnson for San Francisco's seventh walk-off win. Scutaro also doubled and scored the tying run in the ninth to help hand J.J. Putz his second straight blown save.
Sergio Romo (4-2) pitched a perfect 10th for the Giants.
ASTROS 5, PIRATES 1
PITTSBURGH (AP) — Brett Wallace had three hits, including a three-run homer, to lift Houston past struggling Pittsburgh.
Edgar Gonzalez (1-0) picked up his first win as a starter in more than four years, giving up a run on five hits in 5 1-3 innings as the Astros won for just the third time since interim manager Tony DeFrancesco took over two weeks ago. Gonzalez struck out five and walked just one.
Jeff Locke (0-1) ran into trouble early and never recovered as the Pirates dropped their fourth straight in the race for the NL's second wild card spot. Locke surrendered five runs in five innings to remain winless in five big league starts.
CARDINALS 5, METS 4
ST. LOUIS (AP) — Rookie Joe Kelly pitched 6 2-3 effective innings and also doubled, and St. Louis held off New York.
Kelly (5-6) allowed five hits and two runs. He made his second start after a brief stint in the bullpen, and turned in his longest outing of the season.
Jason Motte got his 33rd save in 38 chances.
Skip Schumaker hit a solo homer and Matt Carpenter drove in two runs for the NL wild card-leading Cardinals. Yadier Molina and Allen Craig added RBI singles and Kelly scored a run.
Daniel Murphy and Kelly Shoppach hit two-run homers for New York.
BRAVES 6, ROCKIES 1
ATLANTA (AP) — Kris Medlen struck out a career-high 12 to lead Atlanta over Colorado.
Medlen (7-1) allowed five hits without a walk in his second complete game of the season. He extended his streak of scoreless innings to 34 2-3 — the Braves' longest since Greg Maddux in 2000 — before the Rockies scored an unearned run in the seventh.
The right-hander, who appeared in 38 games in relief before moving into the rotation July 31, improved to 6-0 with a 0.54 ERA in seven starts.
David Ross hit a two-run double in Atlanta's four-run third inning.
Tyler Chatwood (4-4) gave up six runs, five earned, in only three innings with five walks.
MARLINS 7, BREWERS 3
MIAMI (AP) — Jose Reyes drove in three runs and Miami snapped a four-game losing streak with a victory over Milwaukee.
Ricky Nolasco (11-12) gave up three runs, though only one was earned, and nine hits in seven innings. He was coming off his third career shutout, against Washington.
Mike Fiers (8-7) lasted 3 1-3 innings. He gave up six runs — four earned — six hits, walked four and struck out four.
Steve Cishek worked the ninth for his 12th save in 16 chances.
Carlos Gomez hit a two-run home run in the second for the Brewers.
DODGERS 4, PADRES 3, 11 INNINGS
LOS ANGELES (AP) — A.J. Ellis singled in the winning run in the bottom of the 11th inning, giving the Dodgers a victory over the Padres for their second consecutive walk-off win.
Ellis got the game-ending hit off Cory Burns (0-1) after two-out singles by Andre Ethier and Luis Cruz, who had a career-high four hits.
Ethier tied the game 3-all with his 16th homer off Luke Gregerson with one out in the bottom of the ninth.
Brandon League (1-1) got the win with two innings of relief. He gave up one hit, struck out two and walked one.