Shaun Marcum wasn’t supposed to pitch yesterday. He ended up throwing his longest outing of the year.

Coming out of the bullpen, however, didn’t change his luck.

Despite working eight efficient innings and throwing 105 pitches, the veteran right-hander absorbed another disappointing defeat as the Mets fell to the Marlins, 2-1, in a 20-inning marathon at Citi Field.

Marcum’s record dropped to an unsightly 0-7, after he was undone in his final inning of work by Adeiny Hechavarria’s run-scoring single.

“It’s more frustrating that the team’s losing,” Marcum said. “I could care less about my personal record. I’d rather the team win.”

He was brilliant when called upon in an emergency role after manager Terry Collins had burned through his entire bullpen save for Robert Carson. Marcum, who had not pitched since May 31 when he lost to these same Marlins, showed little rust despite the layoff after taking over in the 13th. Relying heavily on his off-speed stuff, he allowed just five hits — all singles — walked no one and struck out seven.

“He was absolutely unbelievable and he gave us every opportunity to win a baseball game, and we couldn’t do it,” Collins said.

Marcum told pitching coach Dan Warthen he was available — as the 31-year-old righty often does between starts — and had no problem coming out of the bullpen, which is where he started his career, though it was an adjustment.