Williams (7-7) won for just the second time in his past 10 starts, giving up four hits with three strikeouts and three walks.
Gio Gonzalez (6-6) remained winless since May 28 despite allowing just two runs, six hits and one walk while striking out four.
Washington lost for the 11th time in 16 games and fell back to .500.
Richard Rodriguez, Edgar Santana, Kyle Crick and Felipe Vazquez followed Williams with one scoreless inning each. Vazquez earned his 20th save in 24 opportunities.
TWINS 8, ROYALS 5
MINNEAPOLIS (AP) — Brian Dozier hit a two-run home run, going deep for the second straight game to give Minnesota a boost on its way to a win over Kansas City.
Lance Lynn (7-7) recovered from a three-run homer by Salvador Perez in the first inning to win his second straight start for the Twins, who used the bottom third of their lineup to launch rallies in the second and the fourth against Royals starter Burch Smith (0-1).
Mike Moustakas homered twice for the Royals, who have the fewest home runs in MLB, but took the Twins deep five times over the last two games of this series. Kansas City has lost 23 of its past 27 games.
RAYS 4, TIGERS 2
ST. PETERSBURG, Fla. (AP) — C.J. Cron’s three-run home run in the seventh inning carried Tampa Bay Rays to its fifth straight win, a victory over Detroit.
Cron’s 18th homer came off Jordan Zimmermann after singles by Kevin Kiermaier and Matt Duffy.
The Tigers, who struck out 14 times against five Tampa Bay pitchers, have lost four straight and 18 of 22.
Rookie left-hander Ryan Yarbrough (8-4) got the win after giving up one hit in three innings of relief. Sergio Romo pitched the ninth for his 11th save in 16 opportunities.
Tigers starter Jordan Zimmermann (4-1) gave up four runs and 11 hits in 6 2/3 innings.
GIANTS 5, CUBS 4, 13 innings
SAN FRANCISCO (AP) — Buster Posey singled off the right-field wall in the 13th inning for his fifth career game-ending hit, sending San Francisco past Chicago.
Brandon Belt drew a two-out walk from James Norwood (0-1). Andrew McCutchen then singled to bring up Posey, who ended the 4-hour, 30-minute game with San Francisco’s first run since scoring four in the first.
Dereck Rodriguez (4-1) pitched three scoreless innings for the win. He also had three of San Francisco’s 16 strikeouts.
Cubs slugger Kris Bryant hit a two-run homer in his return from the disabled list, and All-Star Javier Baez tied the game with a solo homer to start the seventh.