KANSAS CITY, Mo. —Ned Yost sat in an aircraft late Wednesday night, contemplating what had gone wrong over the previous 72 hours. In three games since beefing up their lineup with a trade, the Royals had managed only three runs while getting swept in Baltimore.

The Royals manager eventually settled on the equivalent of a shoulder shrug.

“The ebb and flow of baseball,” Yost said.

A trip home turned the tide once more.

The Royals halted a three-game losing streak with a 6-4 victory Thursday night against the visiting Seattle Mariners. The win preserved the Royals’ standing in the second wild-card spot in the American League. Cleveland beat the Yankees on Thursday, so the Royals remained 2.5 games behind the first-place Indians in the American League Central.

“At the end of the day, we didn’t score enough runs (in Baltimore). We didn’t play well at all in my opinion,” said Royals outfielder Lorenzo Cain, who recorded the game-winning RBI in the seventh on Thursday against the Mariners. “But you gotta turn the page, and you gotta move on to the next series.”

It wasn’t a complete offensive explosion Thursday — the Royals collected eight hits — but after a streak of just three runs in 32 innings, it sure felt like it.

Cain and Melky Cabrera issued back-to-back run-scoring singles in the deciding seventh, and Brandon Moss homered twice in the game.

After 13 scoreless innings dating back to Wednesday in Baltimore, the Royals (56-51) scored in four straight innings — two in the fifth, one in the sixth, two in the seventh and one more in the eighth.

Moss sparked it all with his two-run homer in the fifth, a 427-foot shot that ended a Royals streak of 46 straight innings without a homer.

“I put a better swing on that than I usually do curveballs,” Moss said. “I was happy to hit that one. Obviously that gave us a boost.”

Reliever Ryan Buchter picked up his first victory in a Royals uniform. Kelvin Herrera allowed one run in the ninth but still picked up his 24th save, retiring Nelson Cruz with a man on base. The Mariners (55-55) fell 2 1/2 games behind the Royals for the second wild-card spot.

Yost was ejected for the second straight night, the first time in his career he’s been tossed in back-to-back games. More on that in a bit.

Back to the offense. In Baltimore, the Royals’ lineup failed to make a dent against a rotation with an AL-worst 5.83 earned run average. The opposition on Thursday wasn’t much better on paper. Mariners starter Yovani Gallardo entered the night with a 5.34 ERA.

The Royals had scored only three runs over 32 innings — and zero over the previous 13 innings — before Moss clubbed his first homer of the night. His second came in the eighth.

That’s directly after the deal to bolster the lineup. The Royals acquired Cabrera from the White Sox on Sunday for a pair of minor-leaguers. The Royals won for the first time since that move, with Cabrera playing his part.

Alcides Escobar led off the seventh inning with a single. After an Alex Gordon bunt moved Escobar to second, Escobar advanced to third on an error that also allowed Whit Merrifield to reach first base. Cain drove in Escobar with a single to right, and Cabrera followed with another run-scoring single to give the Royals a 5-3 edge, their first lead in 29 innings.

“People are wondering if we’re in slumps — the bats don’t look any different than when we were swinging the bats good,” Yost said. “Our guys came up with big hits — clutch hits.”

That started an inning earlier. In the sixth, the Mariners elected to intentionally walk Salvador Perez for a preferred lefty-lefty matchup with Mike Moustakas. But Moustakas burned them for a two-out single up the middle to tie the game at 3-3.

Guillermo Heredia had supplied the Mariners a 3-2 lead in the top of the sixth with a run-scoring single off Mike Minor, the first of five Royals to relieve starter Trevor Cahill.

As for that ejection ...

After Mariners third baseman Kyle Seager tucked a ball inside the right-field foul pole for a 1-0 advantage, Mariners first baseman Danny Valencia attempted to replicate the feat. Valencia sliced a ball that hit either the railing or the foul pole first — depending on whom you ask.

The ball was ruled a solo home run, and it was upheld after a review that spanned nearly three minutes. Yost popped out of the dugout to argue the conclusion of the review.

After the game, Yost said he determined the home-run call was correct. Cabrera also informed him the ball hit the pole first.

“You never could really tell (initially) it hit the pole and shot down, but the umpires absolutely got it right,” Yost said.

Both of the Mariners’ solo homers came off Cahill, who made his second start since joining the Royals via trade last month. Just like his first start, he failed to secure five full innings.

On Thursday, he was removed after two outs in the fifth. He allowed only two runs, though that was after Minor stranded two of his runners in the fifth. In two starts with the Royals, Cahill’s ERA stands at 7.27.

“I thought he threw the ball really well,” Yost said of Cahill. “He threw some great change-ups and some great breaking balls and really spotted his fastballs.”

Former Royals outfielder Jarrod Dyson tagged Cahill twice for singles in Dyson’s first game back at Kauffman Stadium since an offseason trade relocated him to Seattle. Dyson also stole a base off Perez for the second time this season.