NEW YORK (AP) -- Mariano Rivera was in rare trouble. Four straight singles trimmed Oakland's deficit to two and left the bases loaded for David DeJesus .
He hit a line drive toward first - and suddenly the game was over. Rivera and the Yankees had caught a break.
DeJesus hit into a game-ending double play when pinch-runner Ryan Sweeney got trapped off first base, and New York held on to beat the Oakland Athletics 7-5 Sunday.
"It's part of the game," Rivera said. "Broken bat, base hit. Line drive, double play. Figure it out."
Bartolo Colon pitched seven effective innings to end a three-start losing streak and Curtis Granderson had a two-run homer for the Yankees. Eduardo Nunez hit a two-run double and catcher Russell Martin was in the middle of everything all afternoon.
New York chased All-Star lefty Gio Gonzalez and returned to its winning ways against the A's when Rivera staved off a ninth-inning rally with a touch of good fortune.
Hideki Matsui 's fifth hit, which matched a career high, loaded the bases with one out. Josh Willingham cut it to 7-5 with an RBI single, the only run Rivera has allowed at home this season.
DeJesus then hit a liner to first baseman Mark Teixeira , and Sweeney broke immediately for second. He had no chance to get back before Teixeira stepped on the bag.
"My run doesn't mean anything. I just kind of got overanxious. I didn't even realize he was playing on the line," Sweeney said.
The 41-year-old Rivera earned his 116th career save of more than one inning, but first this year. He reached 25 saves for the 15th consecutive season, extending his major league record.
"I'd be surprised if someone could outdo that," Yankees manager Joe Girardi said. "That's one of those records I don't think anyone will break."
A one-run loss Saturday snapped New York's 11-game winning streak against Oakland. But the Yankees rebounded behind Colon, taking two of three in the series. The Athletics have lost 10 straight series to New York, an Oakland record against any club.
Matsui tormented his former team again, going 5 for 5 with two doubles and an RBI for the A's. The day before, he homered and scored twice in a 4-3 victory.
The broiling heat subsided a bit, with a game-time temperature of 85 degrees following readings of 93 on Saturday and 100 on Friday night.
A brief shower in the eighth cooled off the crowd of 45,586, just as Oakland mounted a comeback with three doubles off All-Star setup man David Robertson . Kurt Suzuki 's second two-bagger of the game cut it to 6-4, but Rivera retired Cliff Pennington on a broken-bat grounder to end the inning.
Nunez manufactured an insurance run in the eighth, scoring without a throw on Derek Jeter 's RBI groundout against a drawn-in infield.
Andruw Jones had a pair of RBI singles for New York, a big league-best 29-6 in day games. The Yankees have won 16 of 18 against Oakland and 26 of 31 matchups overall since the start of the 2008 season.
The A's are 7-26 in their last 33 road games.
"It's frustrating, but we didn't give up," DeJesus said. "A lot of teams, when Mariano comes in, everyone hangs their heads. Like all right, the game's over. But we didn't feel that way. Just little by little, hit after hit, believed in ourselves. Hit one right at him."
Colon (7-6) allowed two second-inning runs and scattered eight hits in his first win since July 2 against the Mets. The 38-year-old right-hander had dropped three straight starts since winning four in a row.
"My slider was working today. I threw a lot of them for strikes," he said through a translator.
It was Colon's first win after the All-Star break since 2005.
Gonzalez (9-7) lasted 4 2-3 innings, the second time in three starts that he's failed to get through five. Before that, he had pitched into the sixth in every outing this year.
Gonzalez yielded a season-high six earned runs and fell to 0-4 with a 5.59 ERA in five starts against the AL East this year.
"You've got to go out there and attack the zone. You can't be hitting people or putting them on base on walks," Gonzalez said. "Just no explanation for what happened."
Nunez's two-run double over Willingham's head in left put the Yankees ahead 3-2 with two outs in the fourth. An athletic play by Martin helped them protect that slim lead in the fifth.
With a runner on first and two outs, Matsui doubled to right-center. Granderson cut the ball off just in front of the warning track and started a long relay. Second baseman Robinson Cano 's throw home was high, but Martin made a leaping grab and came down in time to tag a sliding Eric Sogard on the hip.
Martin also singled twice, stole a base and threw out a runner attempting to steal. He scored on Nunez's double and Jones' two-out single in the second.
NOTES: Oakland RHP Tyson Ross , on the disabled list since May 20 with a strained left oblique, was slated to throw 65-70 pitches in a rehab start for Triple-A Sacramento. But interim manager Bob Melvin wouldn't commit to putting Ross back in the rotation once he's healthy. ... Matsui also had five hits for the Yankees on July 22, 2007, against Tampa Bay. ... Oakland tied a season high with 15 hits. ... The A's are winless in their past 11 road series. ... New York reliever Rafael Soriano (right elbow inflammation) allowed a solo homer in a one-inning rehab outing for Triple-A Scranton/Wilkes-Barre.