Rivera struck out AL batting leader Adrian Gonzalez with the bases loaded for the final out and Martin hit a go-ahead double in the seventh that sent New York to a 4-2 victory Thursday night despite stranding 12 runners over the first six innings.
Burnett, coming off an awful August, allowed two runs and five hits in 5 1/3 innings after adjusting his delivery. Yankees manager Joe Girardi thought the changes would work.
"I just had a feeling tonight he was going to get it done," Girardi said, "and he did."
Struggling to stay in the rotation after going 1-2 with an 11.91 ERA in five starts last month, Burnett changed the position of his hands at the start of his windup.
"I've only really been working on that for three days. I've been pitching the same way for 11 years so it's a big change, but as the game went on I felt more comfortable," he said. "It all goes down to focus and conviction and that was a lot better."
The Yankees trailed 2-1 when Burnett left, then scored three times in the seventh off Alfredo Aceves (9-2) in a tense game that took 4 hours, 21 minutes.
Nick Swisher started the inning by striking out. Aceves then walked Andruw Jones and hit Jesus Montero, a top prospect making his major league debut, with a pitch. Aceves was replaced by Daniel Bard, who gave up a double to right-center by Martin, the first batter he faced. Two runners scored and Martin went to third on the throw to the plate. Pinch hitter Eric Chavez followed with an RBI single.
"Tremendous," Girardi said of Martin's hit. Bard "is one of the best relievers in the game and we were able to get some runs off him."
The Red Sox threatened in the ninth, loading the bases on walks to Jed Lowrie and Jacoby Ellsbury and a single by Marco Scutaro. But Rivera caught Gonzalez looking at a third strike and picked up his 36th save in 41 opportunities.
"We gave ourselves a chance," Boston manager Terry Francona said.
Dustin Pedroia's two-run homer after a double by Gonzalez gave the Red Sox a 2-1 lead in the fourth. Aceves escaped a bases-loaded jam in the sixth, then struggled in the seventh and took his first loss in relief after winning 18 straight decisions out of the bullpen.
The Yankees moved within a half-game of the first-place Red Sox in the AL East by winning two of three in the series. New York is 4-11 against Boston this season, and the teams have one three-game series remaining at Yankee Stadium from Sept. 23-25.
Cory Wade (3-0) got the win after pitching to just one batter, Lowrie, who ended the sixth by flying out.
Boston starter Jon Lester struggled in each of his five innings, throwing 114 pitches, but gave up only one run. That scored in the first when he needed 43 pitches. Leadoff hitter Derek Jeter struck out, but Curtis Granderson and Mark Teixeira singled and Robinson Cano drove in the run with a double.
"I tried to minimize the damage," Lester said. "I was happy to get out of the first with one and from there on out it was a struggle."
Teixeira left the game in the bottom of the seventh and is day-to-day after being hit by a pitch from Aceves on the side of the right knee in the sixth.
"I don't know if I'll have him (Friday)" in the opener of a three-game series against Toronto, Girardi said. "We'll just wait and see."
Burnett allowed one hit through three innings before giving up Pedroia's homer into the center-field bleachers, his career-high 18th of the year. He hit 17 in 2008, when he was the AL MVP.
"It feels good to keep my team in it," Burnett said. "Obviously, you want to go deeper, but to bounce back after a homer and to go as long as I could go and leave it all out there, it's all I can do."
Aceves is 23-3 in his career. He entered the game as the only pitcher in baseball history to win 23 of his first 25 decisions. ... The Red Sox added first baseman-outfielder Conor Jackson, obtained Wednesday night from the Oakland Athletics, and recalled left-hander Felix Doubront from Triple-A Pawtucket. ... Montero stranded six runners as the designated hitter. ... Bard's streak of eight scoreless outings ended. ... Ortiz extended his hitting streak to 15 games with a single in the second. ... Phil Mickelson, playing in the Deutsche Bank Championship starting Friday in Norton, threw out the ceremonial first pitch. ... The Yankees return home for the opener Friday night of a three-game series against the Blue Jays. Ivan Nova (14-4) pitches for New York against Brandon Morrow (9-9). ... The Red Sox send Andrew Miller (6-1) to the mound against Derek Holland (12-5) in the opener Friday night of a three-game series with the Texas Rangers.