PITTSBURGH -- If things break just right, the Dodgers can mark their 50th anniversary in Los Angeles by clinching the division title at home after edging the Pirates on Thursday in 12 innings, 4-3, and trimming the magic number to seven.

Los Angeles emerged from a 10-game trip against three weak opponents with seven wins, stepping it up in crunch time after stumbling away from home most of the year. Now the club returns for the final homestand of the regular season against teams with the two worst records in the division, San Francisco and San Diego.

They return weary, particularly the bullpen, mostly because rookie starter Clayton Kershaw could log only five innings. Takashi Saito and Cory Wade let leads get away before Jonathan Broxton locked this one down after James Loney's bases-loaded single broke the tie in the top of the 12th.

It wasn't an easy save for Broxton. He allowed a one-out walk to speedster Nyjer Morgan, who stole second and took third on a Luis Cruz line drive that almost amputated Broxton's glove hand, with Broxton retrieving the ball and throwing Cruz out at first.

Manager Joe Torre then went with the matchups instead of the book, putting the winning run on base by intentionally walking left-handed-hitting All-Star Nate McLouth to have the hard-throwing right-hander go after right-handed reserve Jason Michaels.

"One guy's knocked in 90 runs as opposed to 40 and one's left-handed and one's right-handed," said Torre. "I didn't want Russell throwing through, either. It was win or lose at that point."

McLouth advanced the winning run into scoring position by stealing second base without a throw, but Broxton got Michaels on a popup for his 14th save as the replacement for Saito, who hasn't regained the sharpness on his slider or velocity on his fastball to take back the closer job.

Saito, who allowed a tying single to former teammate Andy LaRoche, said he struggled with command of his breaking ball but his arm felt fine, and he expected to be ready with only one day off instead of two.

Torre viewed the win as another indication of his team's growing confidence after Wednesday night's bullpen meltdown resulted in a 15-8 blowout loss. The Dodgers have bounced back from their last three losses with wins.

"Those guys were loose and fine before the game and once we scored two runs [on DeWitt's fourth-inning single], we were in good shape on the bench," said Torre. "This time of year, every game is like a season. With the number of chances we let get away, this was a gift for us."

It wasn't an easy game for the Dodgers, not even with Pirates pitchers issuing 11 walks, three of them scoring, because the Dodgers made two mistakes that easily could have meant defeat.

With two out in the eighth and runners on first and second, Matt Kemp was thrown out trying to steal third base to end the inning.

Then with one out in the 10th and Pirates on first and second, Chan Ho Park fielded Michaels' tapper and threw to second base, but Blake DeWitt was 10 feet behind (instead of covering) the base. DeWitt dived to knock down the ball and threw home, where catcher Russell Martin short-hopped the throw and hung on in a jarring collision with Morgan out.

While the Dodgers again missed injured reliever Hong-Chih Kuo, the most critical performance was from reliever Scott Proctor, who earned the win. For the first time since returning from the disabled list and an elbow injury, he not only pitched on back-to-back days, but he went one perfect inning in a day game after 1 2/3 perfect innings in a night game. In about 20 hours, Torre had 12 relievers pitch 10 1/3 innings.

"This is the whole reason you play this game," said Proctor, who volunteered to pitch a second inning Thursday. "Probably the most rewarding game was when I came back off the DL, because I know what it took, all the hard work of the trainers that helped get me back. This was a good team win. A lot of guys made great plays."

Kershaw struck out five, walked two and was charged with one run on only two hits, but he wasn't pleased with either his curveball command or the burden he placed on the bullpen by running up his pitch count and leaving early.

"We got the win and that's the main thing, but for me, it was just one of those days," he said. "I was just bad with everything. I wish I had gone deeper to give the bullpen a break."