CHICAGO -- Catcher John Baker pitched a scoreless top of the 16th inning, and he scored the winning run in the bottom half on a sacrifice fly as the Chicago Cubs beat the Colorado Rockies 4-3 in a game that started Tuesday night and ended Wednesday morning.

The Cubs loaded the bases in the bottom of the 16th against Rockies left-hander Tyler Matzek (2-5) and finally ended a marathon game on a fly to right by shortstop Starlin Castro.

The game, which lasted 6 hours, 27 minutes, set club records for time for each team. The previous Cubs record was 6 hours, 10 minutes against the Los Angeles Dodgers on Aug. 17-18, 1982. The previous record for the Rockies was 6 hours, 16 minutes on April 17, 2008, against the San Diego Padres.

Baker (1-0) made the first pitching appearance of a pro career that began in 2002. He got the first batter to foul out. After issuing a walk, Baker induced a double-play grounder from Colorado shortstop Cristhian Adames, who was making his major league debut.

Orioles 7, Angels 6 (12 innings)

BALTIMORE -- Manny Machado led off the bottom of the 12th with a home run, giving Baltimore Orioles a victory over Los Angeles.

Machado lined a 1-2 pitch from Cory Rasmus (2-1) into the left field seats. The third baseman hit an RBI double earlier in the game.

Right-hander Ryan Webb (3-1) got the win after escaping a jam and retiring the Angels in the 12th. The Orioles improved to 12-3 in extra-inning games this season.

Phillies 6, Mets 0

NEW YORK -- Left-hander Cole Hamels concluded an impressive July by throwing eight shutout innings, and Chase Utley crushed a grand slam in the seventh inning as Philadelphia beat New York.

Hamels, who has been the subject of trade rumors leading up to Thursday's non-waivers trading deadline, allowed hits to six of the first 16 batters he faced before retiring the final 13.

Hamels allowed only two runners as far as second base and walked none while striking out eight. He improved to 4-1 with a 1.94 ERA in six starts this month.

Reds 3, Diamondbacks 0

CINCINNATI -- Mike Leake pitched seven shutout innings and Todd Frazier went 2-for-4 with an RBI, lifting Cincinnati over Arizona.

Leake (8-9) allowed only five hits with no walks and eight strikeouts. Arizona had a few scoring chances against Leake but couldn't cash in, going 1-for-7 with runners in scoring position and stranding eight.

Didi Gregorius went 2-for-3 with a triple for the D-backs, who were shutout for the eighth time this season.

Rays 5, Brewers 1

ST. PETERSBURG, Fla. -- Alex Cobb stifled Milwaukee for eight innings and Ben Zobrist provided all the offense Tampa Bay needed, knocking in the tying and eventual winning runs with a homer and a double.

Zobrist's one-out double in the eighth off reliever Will Smith broke a 1-1 tie and ruined what had been a stellar start by former Rays pitcher Matt Garza. Pinch hitter Logan Forsythe followed with a run-scoring double to left for a 3-1 lead.

Cobb (16-6) outlasted Garza to win his fifth straight decision, allowing a run on three hits, with two walks and 12 strikeouts. The Rays have won 11 of their last 12 games.

Blue Jays 4, Red Sox 2

BOSTON -- Toronto rookie right-hander Marcus Stroman picked up where he left off in his last outing -- handcuffing Boston.

Stroman, who allowed one hit over seven scoreless innings against the Red Sox on Thursday, was only slightly more generous in this outing. He improved to 7-2 by allowing one run on six hits in seven innings.

The Red Sox got a run back in the ninth when Xander Bogaerts led off with a home run off right-hander Casey Janssen, who then retired the next three batters to earn his 17th save.

Marlins 3, Nationals 0