The Pirates have relied most of this season on a shutdown bullpen to make up for a lackluster offense. Those roles were reversed Tuesday night.

The offense built a big enough lead to protect against a shaky bullpen as the Pirates held on to beat Texas 5-4 at Rangers Ballpark in Arlington.

The Pirates led by as many as four runs in the game but needed reliever Mark Melancon to strike out American League MVP candidate Adrian Beltre with the potential go-ahead run on base to preserve the win.

All-Star relievers Jason Grilli and Melancon allowed earned runs in the eighth and ninth innings after guarding narrow leads most of the season.

"Nobody's more aware of it than the guys on the offensive side of the ball" manager Clint Hurdle said. "They've seen so many times where the bullpen has locked things down. And they've seen games extended where we had to pitch innings where we normally wouldn't have to pitch. But we're all in it together. The offense showed up at a very critical time."

The Pirates led by three runs entering the ninth and Melancon recorded two quick strikeouts before allowing four consecutive singles as the Rangers pulled to within one run. With the potential tying run at third and the go-ahead run on first Melancon stared down Beltre.

"Things like that can happen quick and tonight it did" Melancon said. "I never really lost composure or thought any negative thoughts out there."

Melancon needed three pitches to strike out Beltre to end the game.

"I threw three heaters" he said. "I think he was taking first pitch. Second pitch he fouled back. Third pitch I don't know if he was sitting breaking ball or not but I came back with another one."

It was the 13th save this season for Melancon though likely the most eventful.

"At the end of the day he struck out the side" Hurdle said. "Just a little bit of action in between."