SEATTLE — It was a simple — if not necessarily easy — formula that Scott Servais laid out for his starting pitching-challenged team before Thursday night’s game against the Chicago White Sox.

Needing yet another different starter as a result of the myriad of injuries that have beset the Mariners this season, Seattle turned to rookie Sam Gaviglio.

Not only was Gaviglio the 10th different starter for Seattle this season — the most in the majors — but it was also only the second major-league appearance of the former Ashland High standout’s career.

All Servais wanted, he said, was four or five innings from Gaviglio “to keep us in the game and then we will go from there.”

He got that and more from Gaviglio.

It was the “go from there” part that momentarily proved the problem and needed the Mariners to pull off some bottom-of-the-ninth heroics to emerge with a 5-4 win.

After Gaviglio threw five shutout innings to depart with his first victory potentially at hand, the bullpen blew up, allowing three homers in the seventh and eighth innings to tie the score.

Two came back-to-back with two outs in the eighth inning off Dan Altavilla — solo shots by Todd Frazier and Matt Anderson that made it 4-4.

Frazier hit his to left and Anderson to right as a White Sox team that came in having lost nine of its last 11 games quickly, if not necessarily unsurprisingly given some of the issues for the Seattle bullpen this season, turned Bark in the Park Night from celebratory to here-we-go-again.

But the bullpen blowup merely set up a dramatic ninth.

Taylor Motter led off the bottom of the ninth with a single to right. Motter was erased at second on a bunt attempt by Jarrod Dyson.

But Dyson then beat out a double play attempt to reach second on a Carlos Ruiz grounder to third. Ruiz was out at first on the relay but Dyson — who was running on the pitch — kept the inning alive by beating the throw to second from third baseman Frazier.

The White Sox then intentionally walked Segura bringing up Guillermo Heredia as a pinch-hitter for Ben Gamel.

Heredia then lined a 1-1 pitch to center to score Dyson and give the Mariners the win.

Until the White Sox tied it, what figured to be most noteworthy about the night was a second straight unexpectedly strong starting pitching performance — Christian Bergman threw 7.1 shutout innings in a 4-0 win over the A’s on Wednesday.

Gaviglio, a former standout at Oregon State, wasn’t overpowering but kept the White Sox off balance with a steady stream of curves, sliders, change-ups and a fastball that stayed around 90.

And he got the big outs when he needed them, stranding a runner on second or third in every inning from the second to the fifth.

His final out typified his night.

After hitting Leury Garcia to put runners on first and second, eliciting a visit from pitching coach Mel Stottlemyre, he struck out Yolmer Sanchez on four pitches — each of the strikes a changeup of 82 or 83 miles an hour.

Casey Lawrence then came on to pitch the next two innings.

He was unscathed in the sixth but gave up a two-run shot to Matt Davidson in the seventh that cut Seattle’s lead in half and foreshadowed the sordid events of the eighth.

The Mariners momentarily broke the game open on a three-run homer by Jean Segura capping a rally that started with two outs and no one on. Dyson walked, then stole second and third and then Carlos Ruiz — hitting .125 — walked on a 3-2 pitch. Segura then rocket a blast over the scoreboard in left field to make it 4-0. That also gave Segura a 17-game hitting streak, tying Mike Trout for the longest streak in the majors this season.

Dyson had given the Mariners a 1-0 lead in the bottom of the third in an unlikely — if suddenly not so unfamiliar fashion — hitting a solo home run.

Dyson’s homer was just the ninth of his career but his second in five days. According to ESPN Stats & Info he is tied for the second-fewest career home runs (9) of anyone with more than 1,500 plate appearances (he entered the game with 1,684) ahead of only Ben Revere of the Angels who has seven.

At that point, Seattle appeared in good position to win what would have been its third in four games on this homestand, reviving itself after having lost four in a row to Toronto to end its last trip.

But aside from Dyson and Segura, the Mariners didn’t get much offense otherwise with six hits through eight innings.

After Chicago tied the score in the top of the eighth, Nelson Cruz hit a broken-bat single to lead off the bottom of the inning. But Kyle Seager struck out and the rally quickly fizzled.