Xander Bogaerts knocked in both runs and the Red Sox snapped a three-game losing streak, edging the St. Louis Cardinals, 2-1.

Bogaerts came to the plate in the top of the ninth with the bases loaded and drove the first pitch from Cardinals closer Trevor Rosenthal to center, scoring Yoenis Cespedes from third.

Koji Uehara closed out the game in the bottom of the inning with his 23rd save of the season despite allowing two hits.

The win capped a successful homecoming for new Red Sox starter Joe Kelly, who faced his former club just six days after being traded away.

Kelly didn't pick up the win -- that went to Junichi Tazawa for a perfect eighth inning -- but limited the Cards to a single run over seven innings, allowing just three hits. He fell behind early, allowing a run in the first, but added six scoreless innings thereafter.

After wasting a leadoff double from Mike Napoli in the second and failing to take advantage of an leadoff infield single from Kelly in the third, the Sox pulled even in the fourth and did so after two were out.

Daniel Nava drove a single to right before Bogaerts hit a deep fly to left. Outfielder Matt Holliday drifted back to the fence almost casually, perhaps feeling that the ball was headed out.

Instead, as Holliday lifted his arm, the ball clanged off his glove and rolled away for a double as Nava, running with two outs, scored all the way from first base.