The Twins are searching for bullpen help before baseball’s nonwaiver trading deadline Friday, and it can be argued that their relievers justified that search Tuesday when they faltered in two innings during an 8-7 loss to the Pittsburgh Pirates at Target Field.

Then again, the culprits weren’t the weak links of the bullpen. One, Glen Perkins, is a three-time All-Star closer. The other, Brian Duensing, had allowed three baserunners over his previous 13 ⅔ innings before Tuesday night.

The game ended up as one of those rough nights during which the Twins were knocked down, got back up with a four-run rally in the eighth to tie the score but then watched Jung Ho Kang hit a go-ahead 411-foot homer off Perkins in the ninth.

Perkins was ahead 1-2 on Kang when he threw his normally trusty slider but left it up in the zone, and Kang swatted the ball out to left-center. Perkins, who has blown two save opportunities and has been tagged with two losses in four appearances since the All-Star break, knew the ball was gone and began yelling at himself while Kang flipped his bat and began circling the bases.

Perkins stressed that his problem is a failure to locate his pitches and not his confidence.

“Bad games are going to happen,” he said. “I’ve been saying that all year long, and it stinks that they are lumped together. I can’t do anything but continue to go out and continue to make pitches.”

Manager Paul Molitor sees little wrong with Perkins.

“The atypical season is the one that stays without its hiccups along the way,” Molitor said.

Miguel Sano drew a one-out walk in the ninth but was stranded as closer Mark Melancon (2-1) got the victory.

The announced crowd of 30,795 had its emotions toyed with during the late innings. Both team scored four runs in the eighth to make it 7-7.

With the scored tied 3-3 in the top of the eighth and two Pirates runners on, Paul Molitor turned to Duensing, who has been effective over the past month after a rough start to the season. He struck out Sean Rodriguez for the second out of the inning and had favorable matchups with Jaff Decker, who was 1-for-7 in four games entering Tuesday, and Gregory Polanco, who was batting .164 against lefthanders.

Duensing got two strikes on Decker but ended up walking him to load the bases. Polanco doubled off the right-field wall, clearing the bases for a 6-3 Pirates lead. Neil Walker added an RBI single to give Pittsburgh a 7-3 lead.

As fans began to stream out of Target Field, the Twins roared back with four runs of their own, including a two-run double by Kurt Suzuki.

“It wasn’t looking particularly very good for us,” Molitor said, “but we strung together some good at-bats to match the four they put up.’’

Twins righthander Mike Pelfrey was 5-2 at one point this season, but his win total has been frozen at five since June 7. He was the loser on July 22 against the Angels despite giving up only two earned runs.

And he failed to get out of the sixth inning Tuesday — but at least the Twins got him off the hook.

With the Twins down 3-2 in the sixth, Miguel Sano drew a leadoff walk then scored when Aaron Hicks lined a triple down the right-field line. It allowed them to tie the score after Pittsburgh had taken a 3-2 lead in the top of the inning.

It was also the Twins’ second triple of the game, giving them 28 for the season. They had 27 all of last season.

But the Twins couldn’t make pitches when they needed them.

“There are time when I think about the game and wonder if I did the right thing,” Molitor said of his pitching moves. “But a lot of times you feel that you do, and you just have to deal with the results.”