CHICAGO — Sunday’s game was a tale of two curveballs. One didn’t break enough. One broke too much.

One was smashed into right field off Grant Balfour in the seventh inning for a triple that drove in the tying run.

One bounced past catcher Curt Casali after Javier Baez swung and missed at what should have been the third strike and the second out of the 12th inning.

Instead, the Cubs had two runners on, and one of those runners scored on a single by Anthony Rizzo that gave the Cubs a 3-2 win at Wrigley Field and sent the Rays to another frustrating defeat.

Balfour again couldn’t finish off an inning and Casali had trouble blocking balls in the 12th inning.

Ball game.

The rookie catcher let another pitch from Cesar Ramos bounce away from him with runners on the corners and the Rays employing the five-man infield in hopes of turning an inning-ending double play or cutting down the potential winning run at the plate.

“It’s a terrible feeling, especially the way we were fighting all game,” Casali said. “Close ball game, 2-2, pitchers doing a good job, trying to scrap together some runs and for it to come down like that, it’s disheartening.”

Of course, the offense had a hand in the loss after going 2-for-9 with runners in scoring position and leaving nine runners on base.

Alex Cobb allowed one run in his six innings and Balfour took the mound in the bottom of the seventh with a 2-1 lead after an RBI double by Desmond Jennings in the top of the inning put the Rays in front.

Balfour retired the first two batters before allowing a double to Ryan Sweeney.

Rays manager Joe Maddon could have gone with lefty Jeff Beliveau to face the left-handed hitting Chris Coghlan, but he decided to stick with the struggling Balfour.

Maddon offered two reasons for his move: Coghlan is batting .358 against lefties and .268 against righties, and Maddon was hoping Balfour would retire Coghlan for a feel-good moment.

“For us to pull this whole thing off, we have to get him right,” Maddon said. “That’s the proverbial moment that you’re trying to boost somebody’s confidence and get him going.”

Balfour got the count to 3-2, then hung a curve that Coghlan drilled to the right-field wall.

“That’s been the story of my last three, four outings, getting the two quick outs and then seem to give up a run,” Balfour said. “Just not making the pitch I needed to right there.”

Kirby Yates, Joel Peralta, Beliveau and Brad Boxberger (another two-inning stint) held the Cubs in check through the 11th inning.

Ramos entered in the 12th and allowed a lead-off single to Sweeney. Coghlan moved Sweeney to second base with a sacrifice bunt.

Ramos then got Baez to chase a curveball in the dirt for what should have been the second out, but the ball bounced over Casali’s head. Baez raced to first as Sweeney advanced to third.

“I should block that ball,” Casali said. “He threw a curveball and just caught me in between catching it and blocking it, and that’s what happens when I make a poor decision like that to try to pick it as opposed to block it.”

Said Ramos, “He did everything he could to block it, and it just found a hole.”

Sean Rodriguez, who was playing right field, was brought in as the fifth infielder. Ramos threw another pitch that bounced far enough away from Casali for Baez to advance to second base.

With first base open, Maddon elected not to walk Rizzo.

“Honestly there’s no reason why he can’t get out Rizzo right there or he can throw a ground ball. Cesar can get a ground ball from a lefty, too,” Maddon said. “It’s one of those things, you got to put trust in your guys and see if they can do it.”

Ramos threw a slider to Rizzo that was down and away, but the lefty was able to pull it to right field for the game-winning hit.

Afterward, Casali stood at his locker and accepted responsibility for the loss.