By GIDEON RUBIN, Associated Press

SAN FRANCISCO (AP) — Andrew McCutcheon had two hits, including a two-run homer, Matt Joyce had a key two-run single, and the Pittsburgh Pirates rallied from a four-run deficit to complete a three-game sweep of the free falling San Francisco Giants with a 6-5 victory on Wednesday.

The Pirates won their fourth straight game and sixth in seven. They remain a game behind St. Louis, which beat Houston 8-2, in the race for the NL wild card.

READ MORE: Teachers Union Takes Legal Action Over Sac City Unified's 'Refusal' To Address Make-Up Days Related To Strike

The Giants, who on Tuesday fell out of first place in the NL West for the first time in 97 days, lost their fourth straight. They fell to 9-21, the worst record in the majors since the All-Star break. They dropped a full game behind the Dodgers, who play Philadelphia tonight.

READ MORE: Athletics Snap Out Of Offensive Funk To Beat Twins 5-2

McCutcheon’s homer, his 17th, capped a six-run rally in the fifth inning that chased Giants starter Matt Cain (4-8).

MORE NEWS: La Stella Homers As Giants Beat Rockies Again, 10-7

Copyright 2016 The Associated Press. All rights reserved. This material may not be published, broadcast, rewritten or redistributed.