Bartolo Colon had given up nine hits and three runs over the first four innings of Thursday night’s game against the Braves at Citi Field, and looked every bit like he was headed for an early shower.

But there he was still battling in the eighth inning, trailing 3-1 and doing all he could to keep the Mets in the game. That’s the mandate for a starting pitcher in the big leagues — stay in the game as long as you can and give your team a chance to win.

The Mets had their chances before eventually losing by that 3-1 score to end a four-game winning streak. They loaded the bases in the fifth and had the tying run on base in the eighth, but couldn’t score.

“He gave us eight pretty good innings, but we can’t keep falling behind,” manager Terry Collins said of Colon.

Still, it was a workmanlike performance by the 41-year-old Colon, who is making it difficult for the Mets to decide whether to trade the veteran right-hander before the non-waiver deadline.

The loss prevented the Mets from sweeping the Braves in a four-game series for the first time since 1989. But taking three of four from their division nemesis has the Mets feeling like contenders as the All-Star break approaches.

What’s good about all this is the Mets finally have shown some resilience against a quality team. What’s bad about all this is trading Colon could hurt the Mets’ slim chances of making the postseason.

As he proved again Thursday night, Colon is the kind of pitcher a contending team in need of a starter would covet. He made his 18th start of the season, entering with a serviceable record of 8-7 with a 4.04 ERA. He allowed 10 hits with seven strikeouts and no walks in taking the loss.

Trading Colon and what’s left on his two-year contract worth $20 million should be a no-brainer, but now that the Mets fancy themselves a contender, general manager Sandy Alderson might decide to wait until they have no chance of making the postseason or until a team becomes desperate enough to make him an offer for Colon that he can’t refuse.

Clearly, Collins seems reluctant to move one of his more dependable starters, especially now that Jon Niese is on the disabled list with a shoulder strain. Collins is not only battling to get into a pennant race, but also is trying to keep his job and probably isn’t concerned about the young prospects a Colon trade might bring in return.

The manager insists the division race is “wide open,” and pointed to the multitude of games remaining against division foes.

“You’re not going to win them all, but if you win your fair share, you’re going to be in the hunt,” Collins said.

Still, how long can the Mets wait before dealing Colon, who doesn’t figure into their plans for 2015?

Even this year, the Mets will have six starters for five spots if all are healthy when Niese returns. But if the Mets indeed work themselves into postseason contention — quit laughing — Collins most certainly would rather have Colon on the mound than neophytes like Jacob deGrom and Zack Wheeler.

Alderson also has to keep an eye out for a drop in Colon’s trade value. The right-hander entered Thursday having lost two straight decisions where he allowed a combined 10 earned runs over 13 innings. It looked like he was again going to struggle, following a pattern of early-inning troubles by allowing two runs and three hits in the first and four more hits and another run over the next two innings. But he yielded just one harmless single over his final four innings. Still, his record shows three straight losses.

“I’m just having a little trouble [early],” Colon said. “I’m going to work to change that.”

If the Mets truly believe they’re contenders, then dealing Colon may be last on their list.