"Everything was working for me today," said Martis, 22, who tossed the first complete game by a Washington pitcher in the two-year history of Nationals Park. "I think today was my day."
Seeing Martis' gem helped make up for a rough time for Washington manager Manny Acta, whose team still owns the majors' worst record at 6-17.
"Moments like this, games like this, they're worth five of those losses we had," Acta said. "This is what we're working for here -- to develop these type of kids. Seeing what he was able to do today against the hottest team in the major leagues [is encouraging]."
Martis (3-0) retired the first 14 hitters he faced before Yadier Molina grounded a single through the middle in the fifth. The right-hander, who had never gone more than 6 1/3 innings, struck out six and walked none in a 110-pitch effort.
"He worked us over. Similar outs all day long," Cardinals manager Tony La Russa said. "We didn't test him very well. He was very good, very tough."
The Nationals also got a little luck when Cardinals first baseman Chris Duncan dropped Ryan Zimmerman's foul pop that would have been the last out of the fifth inning. Zimmerman then singled to left to put runners on first and second for Dunn, who hit his seventh homer.
"I've been horrible the past week or so," Dunn said. "To be able to produce in that situation was obviously big for us and for a little confidence booster."
Acta sensed the big blow was coming as soon as he saw Duncan bobble, then drop Zimmerman's pop near the right-field stands.
"It was huge," Acta said. "We were talking among the coaches there and I said right here, we should be able to make it hurt because it's happened to us enough already. We came through."
Colby Rasmus hit his first career homer for St. Louis.
Zimmerman doubled in the first, extending his Nationals-record hitting streak to 21 games, the longest in the majors this season.
Joel Pineiro (4-1) held Washington scoreless until the fifth. Martis reached on a fielder's choice when he failed on a sacrifice attempt and went to third on Cristian Guzman's single to right. Nick Johnson followed with a sacrifice fly to deep center that Rick Ankiel caught before stumbling into the wall.
Zimmerman reached after Duncan botched his foul pop and Dunn hit a shot to right field for his fourth career homer off Pineiro in 16 at-bats.
"That's probably the worst pitch Joel made all day long. He put it on a tee for [Dunn]," La Russa said. "Errors are part of the game. Pitchers picks up the defense. Defense picks up the pitcher."
The error was Duncan's first in 46 career games at first base, and came in his first start there this year. Albert Pujols, who entered leading the National League in RBI and tied for the lead in home runs, got a planned day off.
Rasmus hit Martis' first pitch of the seventh into the right-field stands to cut it to 4-1.
Pineiro allowed four runs -- one earned -- and seven hits in seven innings.
- Washington LHP Joe Beimel, on the 15-day disabled list since April 21 with a left hip flexor strain, started and pitched an inning in a rehab assignment with Class A Potomac on Friday night. Beimel, a reliever, will start again Sunday at Potomac.
- It was the first complete-game win for a Nationals pitcher since Aug. 15, 2006, when Pedro Astacio beat Atlanta.
- Hernandez was a late addition to the lineup in place of 2B Ronnie Belliard, who was benched because he overslept and arrived late at the stadium, Acta said.
- It was the third loss for a St. Louis starting pitcher this season. Cardinals starters are 14-3.