MIAMI — Clayton Kershaw spent the bulk of the evening in the dugout, wearing a blue Dodgers jacket, chatting with teammates and chomping down on a wad of pink bubble gum.

He didn’t win his comeback game.

Still, the NL West leaders were happy just to have their ace back.

Sidelined since June 26 with a mild disk herniation, Kershaw started and pitched three innings in the Los Angeles Dodgers’ 4-1 loss to the Miami Marlins on Friday night.

“You try to look at the positives, I guess,” said Kershaw, who reported no physical problems afterward. “I got to pitch again. That’s always fun.”

Kershaw was more than outdueled by Marlins ace Jose Fernandez (14-8), who tossed seven shutout innings and tied a career high by striking out 14.

Dodgers manager Dave Roberts was thrilled afterward.

“For Clayton to be back on the mound, I think that’s a win for us,” Roberts said. “Fernandez was good, but the No. 1 thing was Clayton got out of this feeling pretty well. We didn’t expect him to be in midseason form anyway.”

Kershaw (11-3) threw 66 pitches, 46 for strikes. He gave up two runs and five hits, struck out five and walked none, his ERA rising just a bit from 1.79 to 1.89. He allowed a home run to J.T. Realmuto in the first, and an RBI single to Chris Johnson — off the glove of leaping second baseman Chase Utley — in the second.

“We did a pretty good job of making him pitch,” said Marlins manager Don Mattingly, the former Dodgers skipper.

Kershaw wasn’t overjoyed with the outing, the three-time Cy Young Award winner and 2014 NL MVP shrugging off notions that it was essentially a rehab or spring start to get his arm ready for the stretch run.

“It’s not spring training for anybody else so it’s not for me, either,” he said. “We’ve got to beat the Giants. We’ve got to win this division. I’m thankful for what the guys did while I was gone. They played unbelievable. They’re still playing unbelievable. I want to be a part of that.”

Miami improved to 5-0 against the Dodgers this season.

Yasmani Grandal hit his 25th homer in the ninth for the Dodgers, who tried to rally against Fernando Rodney before A.J. Ramos came in and closed it out for his 33rd save.

Fernandez was simply dominant, improving to 4-0 all-time against the Dodgers and 28-2 at Marlins Park. There have been 12 games in the majors this season when a pitcher has struck out 14 or more, and no one else has more than one of them.

His 102nd and last pitch — one that fanned Yasiel Puig for No. 14 — hit 98 mph.

“It seems like that’s all I do lately. I can’t pass 14,” Fernandez said.

Kershaw gave up some hard-hit balls, but the most important element of the outing for the Dodgers’ lefty was this: When tested physically, he passed.

Fernandez lined a low offering right back up the middle in the second inning, sending Kershaw spinning 180 degrees and leaving him looking at second base with his left leg outstretched like a hockey goalie making a pad save. And in the third, Kershaw pounced off the mound to field Yelich’s nubber, then spun to make the throw to first and fell back somewhat awkwardly.

Neither instance seemed to bother him.

“We all held our breath a little bit,” Roberts said.

THE DON

Mattingly is the third skipper in the last half-century to start 5-0 against the Dodgers — the team he managed from 2011-15. He joined Jack McKeon (with the Padres in 1988) and Sparky Anderson (with the Reds in 1970).

CELEBRATING PERFECTION

It was the 51st anniversary of the only Dodgers perfect game, Sandy Koufax’s 1-0 gem against the Chicago Cubs. Dennis Martinez — who pitched a perfect game for Montreal at Dodger Stadium in 1991 — threw out one of Friday’s ceremonial first pitches.

TRAINER’S ROOM

Dodgers: OF Andre Ethier (broken right leg) could make his season debut this weekend. … Kershaw will start at Yankee Stadium on Wednesday, back in his regular spot in the rotation.

Marlins: OF Giancarlo Stanton, limited to pinch-hitting duty, struck out with the bases loaded to end the fifth.

UP NEXT

The series continues Saturday with LHP Rich Hill (11-3, 1.94 ERA; 8-0 in his last 10 starts) going for the Dodgers against RHP Tom Koehler (9-10, 3.87).