David Ortiz

David Ortiz scores for the Red Sox in the seventh inning against the Angels in Anaheim, Calif., Saturday night. (Lisa Blumenfeld / Getty Images / August 9, 2014)

Albert Pujols led off with a home run to right-center in the bottom of the 19th inning to lift the Angels past the Red Sox 5-4 in a game that stretched into early Sunday morning in Anaheim, Calif.

The game lasted 6 hours, 31 minutes, the longest in the major leagues this season.

The Red Sox brought in starter Brandon Workman (1-6) to start the 19th and Pujols drove a 3-and-2 cutter into the front row, setting off a celebration that was tempered only slightly as umpires reviewed and quickly confirmed the winning blast. Pujols finished with three RBI and Mike Trout drove in two runs as the Angels snapped a four-game slide and pulled four games behind Oakland in the American League West.

David Ortiz drove in two runs and Dustin Pedroia stole two bases on the same play in the 14th inning and scored twice for Boston. Matt Shoemaker (10-4) struck out four in three perfect innings to earn the win as the Angels staff held the Red Sox to a total of six hits.

The Angels jumped in front in the first inning when Pujols' double to center glanced off Brock Holt's glove as he went into a dive and scored two. Angels starter Garrett Richards, who did not allow a hit through the first six innings, surrendered a single to Pedroia to lead off the seventh before Ortiz delivered an RBI double and Yoenis Cespedes made it three straight hits with a single.

An error on Erick Aybar allowed the tying run to score and another miscue pushed Cespedes to third before Xander Bogaerts' sacrifice fly gave Boston a 3-2 lead. Trout lined his 26th home run over the wall in right-center in the eighth to force extra innings, and the teams traded runs in the 14th on Ortiz's sacrifice fly and Trout's RBI fielder's choice.

GAME NOTEBOOK: Richards ended up charged with three runs - one earned - on three hits in 6 1/3 innings while Boston starter Clay Buchholz threw a season-high 120 pitches over eight innings and yielded three runs on six hits. … Pujols moved over to play third base in the 14th inning, marking the first time he had played on that side of the diamond since June 2012. … Angels OF Josh Hamilton, who struck out with the winning run on third in the 14th, snapped a string of 23 at-bats without a hit with a double in the 17th.