BOSTON -- Yes, the Red Sox were desperate for a win, and they didn't much care how they got it.

What happened Tuesday couldn't be scripted, and it was hardly the way they would draw it up. But in the end, the Red Sox rode an unlikely walk-off hero named Darnell McDonald en route to a thrilling 7-6 victory over the Rangers.

How bad did the Sox need this after starting the season 4-9 and entering the night six games behind the Tampa Bay Rays?

"Desperately," said Red Sox manager Terry Francona. "I thought we played that game with some urgency, which we needed to do. That wasn't the way you draw it up, except for the end. There's something to be said for persistence. We have a lot of work to do, but we hung in there and won a game that was difficult to win."

To get to the winner's circle and snap a five-game losing streak, Boston first had to overcome deficits of 5-1 and 6-2. The Red Sox had to shake off the Rangers stealing nine bases against them, which tied a club record set in 1913 at Washington for most allowed.

"[I'm] pretty concerned," said Francona. "Again, that's a hard way to win. We understand that. We're very aware of that. We're doing the best we can. Guys will work and we're going to try to do better."

Starter Tim Wakefield thought he should take all the blame for all the steals, and not catcher Victor Martinez.

"I can only speak for myself," Wakefield said. "Most of the stolen bases tonight came off of me. It had nothing to do with Victor or [Jason Varitek], whoever was back there. I was just really concentrating on throwing strikes, and I wasn't keeping a very close eye on the running game today. Obviously it showed. They stole nine bases off me in the first six innings. It's something I'm not happy about, but [it's] something I'll continue to work on."

But Martinez was willing to take accountability as well.

"The way they ran the bases, I'm doing the best I can," Martinez said. "I wish I can be perfect, but like I say, I'm doing the best I can. That's me. I'm the one who has to catch the ball and get it out there. I'm not doing it right now. But like I say, it's a long season and I still have a lot of work to do. Like I've always been [doing], I'm never going to give up. I'm going to keep working on it and see what happens."

Even before the game, Red Sox general manager Theo Epstein talked about how much a priority it is for his team to improve at stopping the running game.

"Some have speculated that we don't care about that, that we just want to always make the pitch and don't worry about the baserunner. That's not true," Epstein said. "I almost wish that were true. We care about it. We definitely recognize the importance of stopping the running game, and thus far, we haven't been able to do it. It was an emphasis throughout Spring Training, and thus far, we haven't got the results. We need to continue to work at every aspect of it, and it's multi-dimensional. We need to do what we need to do to improve, because we're giving the opposition an unnecessary advantage right now in that area."

Steals aside, the Red Sox went deep into their bench, with all four reserves -- most dramatically McDonald -- doing something to aid the cause.

The game ended with two outs in the bottom of the ninth, when McDonald drilled a single off the Green Monster against Rangers right-hander Frank Francisco. McDonald, who was called up earlier in the day from Triple-A Pawtucket, made his end-game heroics possible by unloading for a pinch-hit, game-tying two-run homer in the bottom of the eighth.

"I couldn't write a script any better than this," said McDonald. "A lot happened real quick tonight. It was a dream come true. That's the reason I signed over here to play in this type of atmosphere, to play for an organization like this."

In the end, the degree of difficulty was well worth it.

"It's fun to win," said Red Sox second baseman Dustin Pedroia. "A lot of us are used to winning. When you lose a few in a row, it gets tough."

Though there are still 148 games left in the season, the Red Sox know that building an early deficit isn't a good idea in the power-packed American League East.

"It's very important for this team to find a way to win," said Varitek. "Yes, it was very nice and very uplifting."

Kevin Youkilis led off the winning rally with a single that deflected off Francisco. Bill Hall did his job, sacrificing Youkilis to third. The Rangers walked Mike Lowell intentionally. Adrian Beltre popped out for the second out, giving Texas a temporary reprieve.

But for the second time on the night, McDonald delivered. He was mobbed on the outfield grass by his teammates. According to the Elias Sports Bureau, it is the first time since the RBI became an official stat in 1920 that the Red Sox had a game-ending RBI hit from a player making his debut.

"Everyone was involved and there's a lot of enthusiasm," said Francona. "Again, the way the game started, to hear the music downstairs and see those guys' faces after the game, that was important. Now, we need to make that ... catapult us. We need to show up tomorrow and still play better."

This one wasn't pretty at the start. But instead of wallowing in it, the Sox did something about it, ending that frustrating five-game skid during which they didn't hold a single lead.

On a night Wakefield labored (six innings, seven hits, six runs, five walks, a hit batter and two wild pitches), he displayed some grit by staying in the game as long as he did. In fact, Wakefield, even after 115 pitches, told Francona he could go one more inning. Francona respectfully declined, and the bullpen came up big from there.

Manny Delcarmen fired 1 2/3 hitless innings. Hideki Okajima got the final out of the eighth. Jonathan Papelbon earned the win with a scoreless ninth.

"It was a huge win for us today, obviously," said Wakefield. "The way we've been playing hasn't been very good, and it was a huge positive step forward for us to come back in that game and win, especially in the fashion that we did it. The guys never gave up. [We showed] a lot of heart and a lot of desire. The bullpen, after I left, came in and did a great job holding it to six runs. Darnell, that was unbelievable."

McDonald's equalizing blast came against lefty reliever Darren Oliver. Francona sent McDonald up to hit for Josh Reddick, the other outfielder called up from the Minors on Tuesday. Before the game, the Red Sox placed starting outfielders Mike Cameron (lower abdominal strain) and Jacoby Ellsbury (left chest contusion) on the disabled list.

Before McDonald's blast, the last Sox player to hit a homer in his first plate appearance with the team was Orlando Cabrera on Aug. 1, 2004.

Trailing by four in the bottom of the sixth, the Sox chipped away on Reddick's two-out two-run double down the line in left. Josh Hamilton overran the ball, and it bounced on the dirt and appeared to hit a fan before bouncing back into play. However, no interference was called, which allowed Jeremy Hermida to score the second run all the way from first.

In the seventh, with two on and two outs, Francona pinch-hit for David Ortiz with the game still hanging in the balance, something he had never done before. Lowell worked a walk in place of Ortiz to load the bases. That rally wound up falling short, but heroics were in store for the last two innings.

"Wins like this, sometimes, they hopefully have a residual effect," said Lowell. "I think we got outplayed. We got outhustled for those first five, six innings. It didn't look too pretty, but sometimes things really turn around, especially from unexpected sources. Darnell, what a way to have your first game with the Red Sox. That was pretty amazing."