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 (37-48) snapped a six-game losing streak, which matched their longest of the season. Miami (41-44) had its modest 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.

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 Blue 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

DETROIT -- Ian Kinsler, Victor Martinez and Torii Hunter hit home runs in a five-run first inning and Detroit right-hander Max Scherzer limited Tampa Bay to two hits in eight innings.

Scherzer (10-3) gave up a leadoff single but just one hit thereafter, a two-out single by James Loney in the fourth inning, and retired the last 13 batters he faced in the Tigers' fourth straight win.

Detroit spotted Tampa Bay a 1-0 lead in the top of the first but roared back with five runs in the bottom of the inning.

Orioles 5, Rangers 2

BALTIMORE -- Steve Pearce had a career-high four hits and drove in two runs, and Wei-Yin Chen worked six innings as Baltimore completed a four-game sweep of Texas.