Bill Hall opened the ninth with a single against Ronald Belisario (1-1), but was cut down at second on Daniel Nava's attempted sacrifice. After Darnell McDonald struck out, Marco Scutaro walked and Pedroia singled to right on a 1-2 fastball from closer Jonathan Broxton.
"When you go out and the guy's throwing 100 and it looks like he's 9-feet tall, I was thinking I've got to wake up," he said. "I check swung twice. When I check swung, it really wasn't going that good. I just stepped out, thinking I've got to put the ball in play."
Nava slid in headfirst, easily beating the throw from Andre Ethier.
"It's funny. In the minors we're not allowed to slide head first," Nava said. "I was trying to make up for the bunt. I was really chugging around third. I wasn't going to get deked at the plate. You want to forget the bunt, but it was still on my mind."
Dodgers manager Joe Torre felt it was the right time to bring in Broxton.
"With a man in scoring position, that was the only time I was going to bring him in that situation," he said.
Ramirez homered in his second game back at Fenway Park, a sixth-inning solo shot off knuckleballer Tim Wakefield. The former Red Sox star also had his first stolen base since 2008.
Wakefield made his 200th career start at Fenway, tying Roger Clemens for the most in club history.
"I'm very fortunate to be able to wear the uniform for as long as I can and share a record with Roger Clemens," he said.
Jonathan Papelbon (2-3) worked a scoreless ninth for the win.
The Dodgers pushed across two runs to tie it at 4 in the seventh. Garret Anderson doubled and scored on Blake DeWitt's double to right. DeWitt advanced to third when Hall misplayed a carom for his second error of the game. Manny Delcarmen relieved Wakefield, and Matt Kemp tied it with a sacrifice fly.
"You know you're in a fight when you play in this ballpark," Torre said. "We were able to fight our way back but we just couldn't get ahead."
Martinez connected in the fourth, driving a 3-0 pitch from Vicente Padilla over the wall in right to give Boston a 3-1 lead.
Padilla said through a translator that Martinez surprised him.
"You have to throw a strike in that situation. It's part of the game," he said. "It could be a ground ball, but it could also be a home run."
Ramirez homered into the second row of Green Monster seats to cut it to 3-2 in the sixth. As he rounded the bases, he was serenaded with a mixed response of cheers and boos -- much like most of his first game back on Friday night.
"He certainly is comfortable hitting in this park," Torre said.
Ramirez also singled, stole second and scored on Anderson's single in the second, giving the Dodgers a 1-0 lead. Boston tied it on Nava's RBI double in the bottom half.
Wakefield gave up four runs, three earned, and five hits in 6 1/3 innings.
Padilla made his first start since going on the disabled list April 23 with an inflamed nerve in his right arm. He gave up four runs and five hits in 5 1/3 innings.
Red Sox OF Mike Cameron, who has been hampered by an abdominal strain, got the day off. ... Padilla fanned David Ortiz on a 95 mph fastball in the third and threw him a 54 mph curve in the sixth. ... Dodgers reliever Hong Chih-Kuo has retired all 22 left-handed hitters he's faced this season, striking out 11. ... Ramirez was 6 for 26 against Wakefield with no homers before Saturday. ... Former Dodgers manager Tommy Lasorda was at the game. ... Wakefield remained 0-4 at Fenway Park this season. ... Dodgers 1B James Loney made a nice grab of a foul pop, leaning into a photographers' pit.