Carlos Martinez \ (file photo/Bill Greenblatt, UPI)

Carlos Martinez \ (file photo/Bill Greenblatt, UPI)

Carlos Martinez’s scoreless streak came to an end, but he fanned a career-high 11 batters and the St. Louis Cardinals took down the Los Angeles Dodgers 2-1 in a pitchers’ duel on Friday.

Martinez (6-2) was coming off 20 1/3 scoreless innings over his last three starts. He also had 21 strikeouts during that stretch.

The young righty walked four and gave up three hits over seven strong innings in this one.

His only blemish came in the second inning, when a pair of walks led to LA’s lone run. Alberto Callaspo reached on balls before Scott Schebler and Enrique Hernandez singled to load the bases with no outs.

Dodgers starter Brett Anderson went down swinging, but Martinez walked Joc Pederson to force in a run. Jimmy Rollins’ double-play grounder ended the inning and stranded three.

“It was a good night,” Martinez said. “I was overthrowing early and then I settled down. I stayed focused. I mixed things up a lot.”

Anderson (2-4) was tremendous over his first seven innings but lost the game in the eighth. He was charged with both runs on four hits over 7 2/3 innings.

“Brett pitched really good,” said Dodgers manager Don Mattingly. “Unfortunately he got the L.”

The Cardinals did not put a runner in scoring position until the top of the eighth, when Yadier Molina walked and Jason Heyward reached on an infield single.

Tony Cruz advanced the runners with a sacrifice bunt, and Pete Kozma — who ran for Molina — scored when miscommunication on Kolten Wong’s grounder led to another infield single.

Matt Carpenter made it 2-1 with his sacrifice fly to right.

Randy Choate and Kevin Siegrist took care of the eighth inning in relief of Martinez, and Trevor Rosenthal tossed a 1-2-3 ninth to record his 18th save.