MLB: Baltimore Orioles at Boston Red Sox

Red Sox right fielder Mookie Betts rounds second base to score the game-winning run on a hit by third baseman Rafael Devers against the Orioles during the ninth inning at Fenway Park on Sunday. USA TODAY SPORTS

Mookie Betts sprinted home from first base on a Rafael Devers single in the bottom of the ninth inning to lead the Boston Red Sox past the visiting Baltimore Orioles, 5-4, in each team’s season finale Sunday.

Betts’ mad dash after the ball deflected off shortstop Richie Martin and into right field helped the Red Sox (84-78) avoid a three-game sweep to end the year. Orioles right fielder Stevie Wilkerson appeared to not take note of Betts running home on the play, allowing him to score easily on the slide.

An inning prior, Wilkerson had robbed Jackie Bradley Jr. of what would have been a go-ahead two-run home run with an incredible leaping grab in right that saw Wilkerson roll over the top of the bullpen wall after making the catch.

Despite the win, Boston was unable to hold onto a 4-3 lead taken in the seventh inning that would have made a 20-game winner out of Eduardo Rodriguez. Matt Barnes served up a game-tying single to Jonathan Villar in the eighth inning.

Brandon Workman (10-1) earned the victory by striking out the side in the top of the ninth. Dillon Tate (0-2) suffered the loss for the Orioles (54-108).

In the seventh, Xander Bogaerts snapped a 3-3 tie with an RBI single that drove home Devers, who had just doubled for his 200th hit on the season. Devers finished the game with three hits and 201 total to cap a breakout year.

Rodriguez pitched seven innings, giving up three runs on four hits and two walks with eight strikeouts. He threw 115 pitches as he sought to become the first Red Sox left-hander to win 20 games since Mel Parnell in 1953.

Boston trailed 3-2 when it loaded the bases with no outs in the sixth inning. Christian Vazquez knotted the score with an RBI single, but the team couldn’t take the lead then.

Baltimore first broke through with a three-run third inning, and Boston answered with two in the bottom of the frame.

Chandler Shepherd started for the Orioles and went five innings, surrendering three runs (two earned) on five hits and a walk. He struck out six.