MIAMI -- The Philadelphia Phillies scored two runs in the top of the ninth inning to defeat the Miami Marlins 5-4 on Thursday night.

The Phillies snapped a six-game losing streak, which matched their longest of the season. Miami had its two-game win streak halted in a game that featured lead changes in the sixth, eighth and ninth innings.

The Phillies trailed 4-3 entering the ninth but rallied against Marlins closer Steve Cishek (4-4). Pinch-hitter Tony Gwynn Jr. walked and raced to third on Ben Revere's single. After Revere stole second, Jimmy Rollins tied the score on a groundout. The Marlins looked like they might escape on a grounder that appeared to be a double-play ball, but second baseman Donovan Solano bobbled the ball and could only get one out, allowing Revere to score the winning run.

Jonathan Papelbon pitched a scoreless ninth for his 19th save of the season.

Dodgers 3, Rockies 2

DENVER -- The surging Los Angeles Dodgers lost the lead late but climbed back into first place in the National League West after defeating Colorado.

The Dodgers' 14th win in their past 20 games coupled with San Francisco's loss to St. Louis earlier in the day moved the Dodgers one-half game ahead of the Giants in the division. The Rockies' misery continued as they lost for the 15th time in 17 games and their fourth in a row.

Closer LaTroy Hawkins (2-2) walked Matt Kemp on four pitches to open the ninth. Kemp took second on Scott Van Slyke's slow roller to second and scored when Juan Uribe scorched a grounder past second baseman DJ LeMahieu. The hit was Uribe's third of the game.

The beneficiary of the rally was Zack Greinke (11-4) who gave up a run in the eighth but moved into a tie for the National League lead in wins.

Angels 5, Astros 2

ANAHEIM, Calif. -- Matt Shoemaker rebounded from the worst start of his career with six strong innings, leading the Los Angeles Angels over Houston.

Shoemaker was scorched for eight runs and 11 hits on June 27 in Kansas City, marking the only start of his career in which he gave up more than three earned runs. He responded with a nice effort against the Astros, giving up two runs, seven hits and three walks to improve to 6-2.

Third baseman David Freese had two hits, including a two-run double in a decisive four-run fourth inning for the Angels. Center fielder Mike Trout and second baseman Howie Kendrick also had two hits each for the Angels, who remain hot at home.

Astros starter Brett Oberholtzer (2-7) gave up five runs, nine hits and three walks in 6 1/3 innings. The Astros had eight hits in the game, three of them by Houston second baseman Jose Altuve, who increased his major league-leading hit total to 121.

A's 4, Blue Jays 1

OAKLAND, Calif. -- Right-hander Sonny Gray allowed one run in seven innings and Oakland beat Toronto in the opener of a four-game series.

Gray (8-3) gave up four hits in his second career start against Toronto, striking out five, walking three and winning his second straight decision. Blue Jays knuckleballer R.A. Dickey (7-7) lost his fourth consecutive start for the first time in a season since 2004.

The A's snapped a three-game losing streak and improved to 52-33, the best record in majors.

The A's took a 2-1 lead into the bottom of the eighth inning and added two runs. Craig Gentry hit a leadoff single and scored on John Jaso's double to right field. Gentry took third on Munenori Kawasaki's errant throw home and scored on Alberto Callaspo's sacrifice fly.

The Jays used a replay challenge to have one of their own runners called out, which allowed Toronto to take a 1-0 lead in the top of the second inning. Oakland played the game under protest.

Yankees 7, Twins 4

MINNEAPOLIS -- New York scored four runs in the fifth inning and three in the seventh to beat Minnesota.

The offensive support was more than enough for Masahiro Tanaka, who picked up his 12th win despite posting some of the worst numbers of his brief 17-game major league career. For the first time since coming over from Japan, he did not have a quality start and allowed nine hits and four earned runs -- both career highs -- while striking out a career-low three in seven innings.

New York led by one through six innings after an RBI groundout by Kendrys Morales made the score 4-3. But New York broke through with their second big inning of the night in the seventh, getting an RBI double from Brendan Ryan and a run-scoring single by Brett Gardner. Derek Jeter knocked in another run with a fielder's choice to make the score 7-3.

Tigers 8, Rays 1