The Pittsburgh Pirates were trailing by three runs in the ninth inning, facing one of baseball’s best closers and on the brink of being swept by the Cleveland Guardians.

Somehow, they found an Easter egg.

Boosted by back-to-back doubles from Tommy Pham and Adam Frazier at the bottom of the order, the Pirates rallied to send the game into extra innings.

But Kyle Manzardo’s sacrifice fly to left field scored automatic runner Jhonkensy Noel, and the Guardians held on for a 5-4 win Sunday afternoon before 12,433 at PNC Park.

After taking three out of four games against the Washington Nationals, the Pirates (8-15) were swept by the Guardians to end the seven-game homestand. The Pirates, who are off Monday, head to Los Angeles for a six-game road trip with three games each at the Angels and Dodgers.

“We’ve got to get something going and be consistent with it,” Pirates manager Derek Shelton said. “Right now, we’re not doing that. We won three of four then we lose three. We just need to be more consistent.”

It marked the third consecutive game the Pirates failed to score a run with Mitch Keller on the mound, a stretch of 1813 scoreless innings. He threw strikes on 68 of 101 pitches, but the Guardians fouled off 10 balls in a 31-pitch fifth inning to run up his count.

“Any pitcher that pitches and they don’t get run support, there’s probably some frustration there,” Shelton said. “I think credit to Mitch, he’s not letting any of that show.”

Keller gave up five hits and two walks in five innings, his lone runs coming in the third on a 362-foot, two-run homer by Steven Kwan, who went 5 for 12 with three RBIs in the series.

“Anytime you go out there, you’re trying to act like any run is the most important run you’re going to give up,” Keller said. “So, ideally, every time I go out there, I’m thinking it’s a zero-zero ballgame, every single time. Whether we’re putting up 10 or putting up zero, I’m going out there with the same mentality every single time. I honestly try not to look at the score, because if you do get into those ballgames when it’s a 10-run lead, you can ease up a little bit. I’ve learned my lesson to not look at the score.”

Even more frustrating for the Pirates was that Bryan Reynolds hit a fly ball to center at a 105.8 mph exit velocity in the first and Alexander Canario connected on a pair of pitches at 106.5 mph in the second and fourth innings, and all three stayed in the park for outs. Reynolds went 3 for 5, but Canario was 0 for 3.

“Reynolds and Canario probably should have had at least a couple homers,” Frazier said. “When you’re hitting the ball 106 at 30 degrees it should be a homer, and they’re running in on them. So I don’t know if that’s the wind or baseballs or what, but it’s tough luck. We’ll keep swinging, and it’ll start turning.”

The Pirates had tough luck in the fourth, when Andrew McCutchen reached on a fielder’s choice, advanced to second on Joey Bart’s single and tagged to third on a deep fly ball to left field by Canario to put runners on first and third. But Manzardo snared Jared Triolo’s sharp grounder down the first-base line to prevent the Pirates from scoring.

Justin Lawrence replaced Keller in the sixth but hit Carlos Santana with a pitch and gave up a double off the Clemente Wall to Gabriel Arias to put a pair of runners in scoring position with no outs. A pair of solid defensive plays stopped the Guardians from scoring. Triolo fielded Angel Martinez’s grounder and threw to third, where Ke’Bryan Hayes fired home to get Santana out. Austin Hedges hit a sharp grounder to second base, and Frazier’s throw to home plate beat Arias’ slide. Then Canario caught Rocchio’s line drive to center to end the frame.

The Pirates responded with their first run in 14 innings, after they followed Saturday’s 3-0 loss with five scoreless innings against Cleveland lefty Logan Allen. Reynolds hit a one-out single to left field and scored on McCutchen’s double down the left-field line to cut it to 2-1.

After walking Bart, Allen got Canario looking at a called third strike on a sweeper for the second out. The Guardians turned to righty Paul Sewald, whose throwing error trying to pick off McCutchen at second put runners at the corners. But Sewald got Triolo swinging for a strikeout to end the inning.

Then Manzardo went deep in the seventh for the second straight game. After leading off the seventh on Saturday with a solo homer off Paul Skenes, Manzardo smacked a 1-0 fastball 374 feet to right for his sixth homer and a 4-1 Guardians lead.

The Pirates’ last chance came down to the ninth against Emmanuel Clase. Enmanuel Valdez drew a leadoff walk, and Pham doubled to deep center to put runners on second and third for Frazier, who drilled a two-run double down the third-base line to cut it to 4-3. Frazier hesitated to tag on Kiner-Falefa’s flyout to left but stole third base and scored on a Hayes single through the right side to tie the score. Reynolds beat out a grounder when Clase couldn’t corral the ball, putting runners on first and second for McCutchen, who grounded into a 6-4-3 double play to send the game into extra innings.

“I was proud of our group because they continued to go,” Shelton said. “You’re talking about one of the best closers in the game, and we put ourselves in a position where we tied the game and had an opportunity in extra innings. Extra innings, sometimes, kind of become a crapshoot.”

Frazier made a diving stop to rob Ramirez of a hit to start the 10th, but it allowed Noel to advance to third. Manzardo hit a deep fly to left, allowing Noel to score the go-ahead run.

Bart drew a leadoff walk in the bottom of the 10th, and automatic runner Jack Suwinski advanced to third when Oneil Cruz grounded into a double play, but lefty Joey Cantillo got Valdez to fly out to right to end the game and earn his first save.

“It’s tough,” Frazier said. “That’s a good pitching staff over there. They’re one of the best in the game. You know it’s going to be tough when they come into town. They play the game the right way over there, so you just keep fighting. It’s one pitch at a time. They got to us these last few days, so we’ll try to put that behind us, go out West, take a day off, which will be good for us, and try to get the Angels.”