DETROIT (AP) -- The Minnesota Twins know they can't keep blowing big leads if they want to stay in the playoff race.
Brian Dozier and Miguel Sano homered as the Twins won in another topsy-turvy matchup, beating the Detroit Tigers 6-4 Sunday for their seventh victory in eight games.
Minnesota blew an early 4-0 lead before Byron Buxton hit a tiebreaking single in the eighth inning. A day earlier, the Twins trailed 5-0, rallied for an 11-6 lead, then lost to the Tigers 12-11 on Justin Upton's two-run homer in the ninth.
"All three games here were a struggle," Twins manager Paul Molitor said. "We really talked about bouncing back after last night, and now we can feel good about getting out of here with a series win."
Buxton drove in two runs for the playoff contenders. Detroit has lost seven of nine.
Minnesota catcher Chris Gimenez had three passed balls in the fifth inning. One toss from starter Ervin Santana that went through his legs was called a wild pitch, preventing Gimenez from tying the major league record of four passed balls in an inning, set by Ray Katt of the New York Giants in 1954 and tied by Geno Petralli of the Texas Rangers in 1987.
"I haven't had to watch too many innings like that," Molitor said. "That was tough. It sucks the air out of the team, but we survived it."
Tyler Duffey (2-3) pitched 1 2/3 scoreless innings. Trevor Hildenberger struck out Upton with a runner on first to end the eighth, then pitched the ninth for his first career save.
Hildenberger struck out James McCann to end the game.
"He's throwing sidearm, so it is a release point that you don't see very often, and he's got a great changeup," McCann said. "After you see his fastball, it feels like you are waiting all day for the changeup to get to home plate."
It was 4-all when Bruce Rondon (1-3) walked the first two batters in the Minnesota eighth. Rondon was optioned to Triple-A Toledo after the game.
"That's a point where we need to keep the score where it was, and he couldn't do it," Tigers manager Brad Ausmus said. "That was his inning to pitch, but I knew I had to get someone up in the `pen when his first pitches weren't close."
The second hitter in the inning, Gimenez, was trying to bunt, but still ended up walking on a 3-1 pitch.
"When they are giving you an out, you have to be able to take it," Ausmus said.
Warwick Saupold relieved and Jorge Polanco put down a sacrifice bunt. The Tigers were looking for a safety squeeze from Buxton, but he lined an RBI single to center. Ehire Adrianaza followed with a sacrifice fly.
"In that situation, you don't want to hit the ball to third and not get the runner in," Buxton said. "I didn't want to do too much, just get a pitch that I could shoot back up the middle. He left one of the plate that I could handle."
Tigers starter Matthew Boyd allowed four runs in 5 2/3 innings, while Santana gave up four runs in five innings.
Dozier hit Boyd's third pitch over the Tigers bullpen for his 23rd homer of the season, including six leadoff shots.
Eddie Rosario singled in the second, moved up when Boyd walked Gimenez, took third on Polanco's sacrifice bunt and scored on Buxton's safety-squeeze bunt.
Sano made it 4-0 in the third with his 26th homer of the season.
John Hicks had a sacrifice fly in the Detroit fourth, and the Tigers loaded the bases later in the inning, but Santana struck out Andrew Romine and Jose Iglesias to escape.
The Tigers tied the game in a bizarre fifth inning that included an error, the three passed balls, a wild pitch and a hit batter.
Twins: With a day off on Monday, the Twins will skip rookie LHP Dietrich Emms' spot in the rotation and make him available in the bullpen. He is scheduled to start again on Saturday.
Tigers: 2B Ian Kinsler (hand) and 1B Miguel Cabrera (back) both sat out the game after sustaining minor injuries on Saturday. Kinsler was hit with a pitch, while Cabrera left the game with back tightness.
Twins: Minnesota is off on Monday before starting a three-game home series with the Cleveland Indians on Tuesday. Bartolo Colon (4-9, 6.77) is scheduled to start the opener for the Twins.
Tigers: The Tigers travel to Texas for a three-game series against the Rangers. Michael Fulmer (10-9, 3.59) was activated from the disabled list after the game and will start Monday's opener.