SANTA CLARA, Calif. -- Christian McCaffrey scored on a go-ahead 2-yard run in the fourth quarter and San Francisco's defense did the rest, sending the 49ers to their second straight NFC title game with a 19-12 victory over the Dallas Cowboys on Sunday.
The 49ers (15-4) used back-to-back long scoring drives in the second half to wear down the Cowboys (13-6) and win their 12th straight game. San Francisco advanced to play the Eagles in the NFC title game next Sunday in Philadelphia after losing in that round to the Rams a year ago.
"Man, we're just excited that we won," rookie 49ers quarterback Brock Purdy said. "Everyone did their part. It's playoff football, it's never easy, but we're moving on."
The Cowboys lost for the record seventh straight time in the divisional round and have failed to make it to the NFC title game since winning their fifth Super Bowl title following the 1995 season.
Dak Prescott threw two interceptions and Brett Maher missed his fifth extra point of the postseason when his attempt was blocked. He later made two field goals.
The Cowboys had a shot when they took over at their own 18 with 2:59 remaining, trailing 19-12 after Robbie Gould's fourth field goal of the game capped a nearly eight-minute drive.
But Prescott threw two straight incompletions and was sacked on third down. Coach Mike McCarthy opted to punt on fourth-and-10 with all three timeouts left.
Purdy started the next drive with a 16-yard completion to George Kittle and San Francisco didn't give the ball back to Dallas until there were 45 seconds left. The Cowboys took over at their 6 and never got close from there.
Purdy, the last pick in the draft last April, improved to 7-0 as a starter since replacing an injured Jimmy Garoppolo early in Week 13. He went 18 for 28 for 215 yards with no turnovers against the Cowboys, joining Joe Flacco (2008) and Mark Sanchez (2009) as the only rookie QBs to win two playoff starts.
"Wow. Brock Purdy getting us to the NFC championship game? I mean, he's only won I think like seven in a row now. Good job, Brock," Kittle said. "He's playing at a high level, getting our best players the football, he's awesome and confident in the huddle. He's just doing a great job."
The 49ers took the lead on the first play of the fourth quarter when McCaffrey capped a 91-yard drive with a 2-yard run.
The drive featured a juggling 30-yard catch by Kittle and a pair of defensive holds against Dallas -- including one on Donovan Wilson near the goal line that negated a third-down sack.
"I was like, you know what, how can I make this as dramatic as possible?" Kittle said of his spectacular catch. "Just shout-out to Brock: I actually wasn't even in progression and he still found me, so that's all that matters. So I just appreciate him giving me a shot at catching the ball."
Maher made his second field goal of the game when he converted from 43 yards out to cut San Francisco's lead to 16-12.
The NFL's top two scoring teams over the past 13 weeks had trouble getting going as the defenses led by All-Pros Nick Bosa of San Francisco and Micah Parsons of Dallas controlled the play.
The Niners picked off Prescott twice in the first half, turned those into field goals by Gould and led 9-6 at the break.
The Cowboys scored the only TD of the first half with Prescott connecting with tight end Dalton Schultz for the third time this postseason. But Maher's low extra-point attempt was blocked by Samson Ebukam.
Maher got some redemption when he made a 25-yard field goal that tied the game at 9 early in the third quarter after Ray-Ray McCloud fumbled a punt return at the San Francisco 21.
JUST FOR KICKS
The Cowboys' decision to stick with Maher after his four missed extra points last week looked questionable when he missed the early extra point. Maher's five missed PATs are the second most by any NFL kicker in the playoffs. Roy Gerela missed six tries in 43 attempts in the 1970s for Houston and Pittsburgh.
There had been a dustup pregame when Maher was warming up. Trent Williams and other 49ers players tried to interfere with his attempts from San Francisco's side of the field, leading to a brief argument.
Cowboys: RB Tony Pollard left late in the first half after injuring his left ankle while getting tackled following a reception. He didn't return to the game. ... DT Calvin Watkins (calf) left in the first half.
49ers: DE Charles Omenihu (oblique) left briefly in the first half but returned to the game.
The 49ers would reach their second Super Bowl in the past four seasons with a win at Philadelphia.