Well, hey, the Royals sure needed this, didn’t they? “This” being defined as the Houston Astros playing to form when the Royals desperately needed them to do do.

The Royals rallied Tuesday for a 7-3 victory at Minute Maid Park by scoring all seven runs against the Astros’ bullpen and with the aid of some atrocious defense.

So what?

The Royals ended their four-game losing streak, pulled back to .500 at 21-21 and avoided the possibility of getting swept by the Astros. And how bad would that have been? Hold on, that’s coming.

“That losing streak, that weight, is something that’s in the past,” said shortstop Alcides Escobar, who contributed two RBIs to the comeback.

“It’s nice when you come back like that in that situation, but you just keep playing hard. If you lose one game, two games or five games, you keep playing hard.”

It was fitting, perhaps, that Mike Moustakas, mired in a seasonlong slump, tied the game with a RBI single that ignited a four-run eighth inning.

“It felt good,” he admitted. “I was oh-for-whatever it was (18). To get that hit in that situation was big for us. Those are the situations I want to be in all of the time.”

George Kottaras followed with a bases-loaded walk, and the Royals had a 4-3 lead.

“As soon as he walked up there,” manager Ned Yost said, “I knew we were in pretty good shape. You just know, in those types of situations, he’s not going to come out of his approach. He’s just not.

“You’d better throw him strikes or he’s going to take a walk.”

The Royals turned 4-3 into 6-3 when Escobar hit a hopper to second, which could have been an inning-ending double play. At most, it should have resulted in a one-run fielder’s choice.

But Astros shortstop Marwin Gonzalez, after getting the force, threw wildly to first, which permitted another run to score.

Thereafter, it was just a matter of getting six outs.

Aaron Crow replaced Bruce Chen, 3-0, after Jimmy Paredes’ leadoff single in the eighth. It was Paredes who earlier provided the Astros with a 3-0 lead with a two-out homer in the fourth against Royals starter Wade Davis.

Crow got a double play and a strikeout. Greg Holland closed out the victory in a non-save situation.

“We have all been trying to get out of (this slump),” Chen said. “We’ve been trying to relax. And tonight, everyone did their jobs.”