SAN FRANCISCO (AP) -The Dallas Cowboys decided it’s much better to be on the winning side of a dramatic comeback.

Keyshawn Johnson caught a 14-yard touchdown pass from Drew Bledsoe with 1:51 to play, and the Cowboys rallied from a 12-point deficit in the fourth quarter for a 34-31 victory over the San Francisco 49ers on Sunday.

Johnson’s score capped a precise 76-yard scoring drive by the Cowboys (2-1), who fell behind early but rallied late in their third straight nail-biting game of the season.

Bledsoe, the veteran acquired for his calm leadership as much as his arm, was 24-of-38 for 363 yards, passing Joe Montana for eighth place on the NFL’s career yards passing list with his first 300-yard game since Sept. 14, 2003. Terry Glenn had 137 yards receiving and Julius Jones rushed for two scores.

The Cowboys must be hoping for a relaxing game soon. Dallas won its opener with an end-zone interception on the final play at San Diego, but Washington threw two long TD passes in the final 4 minutes last Monday to beat the Cowboys in a 14-13 heartbreaker.

Johnson also caught a 2-point conversion pass after his TD, and Dat Nguyen intercepted Tim Rattay’s tipped pass at midfield with 54 seconds left to preserve the Cowboys’ victory over their longtime rivals.

Brandon Lloyd caught an 89-yard touchdown pass and another scoring toss from Rattay for the 49ers (1-2), who seemed ready to match their win total from last season, when they finished with the NFL’s worst record.

Safety Tony Parrish returned one of his two interceptions for a score, but the 49ers’ defense broke in the final minutes.

Rattay was 21-of-34 for 269 yards and three TDs, but the 49ers scored just once after a second-quarter flurry similar to their impressive effort two weeks ago against St. Louis.

The clubs have one of the NFL’s most enduring rivalries stretching to the early 1970s, when they met in the first of six NFC championship matchups through 1994. Five years ago Saturday, Terrell Owens celebrated two scores at Texas Stadium on the star logo at midfield, stirring bad blood between the clubs.

In addition to his prolific passing numbers against the 49ers’ suspect defense, Bledsoe had just his seventh TD rushing in 13 NFL seasons in the second quarter.

Dallas made two lengthy scoring drives in the first half, starting inside its 20 both times. But early on, the Cowboys’ consistency couldn’t match the 49ers’ knack for big plays.

Lloyd slipped behind the Dallas secondary midway through the second quarter for the 49ers’ longest pass since 1991 – and the second-longest pass ever completed against the Cowboys.

Sixty-one seconds later, Parrish stepped in front of Bledsoe’s pass and returned it 34 yards untouched. It was the first interception in a Dallas uniform for Bledsoe.

Parrish then intercepted a tipped pass on the Dallas sideline late in the third quarter, setting up Lloyd’s 13-yard TD reception to put San Francisco up 31-19.

The Cowboys pulled within five points on Jones’ 1-yard run early in the fourth period. After the clubs traded punts and turnovers for most of the quarter, Dallas calmly drove for Johnson’s go-ahead score. Moments earlier, 49ers linebacker Julian Peterson was forced to leave the game with a strained hamstring.

Only subscribers are eligible to post comments. Please subscribe or to participate in the conversation. Here’s why.

Use the form below to reset your password. When you've submitted your account email, we will send an email with a reset code.