FOXBOROUGH, Mass. — Appearing in only his second career game, LaMichael James came through with a heroic 62-yard kickoff return Sunday night to set up the 49ers’ go-ahead touchdown in their 41-34 win over the New England Patriots.

It was just what his teammates ordered. James said “everybody” pleaded for him to come through with a “boost” for positive field position. “Anytime teammates say anything like that, it makes you want to go fight for them and make a play,” James added.

James’ fourth return of the game and seventh of his career put the 49ers at the Patriots’ 38-yard line, and Colin Kaepernick threw a touchdown pass to Michael Crabtree on the 49ers’ ensuing snap for a 38-31 lead with 6:25 left.

“That was a huge part of it, that set up Crabtree’s touchdown,” Kaepernick said of James’ return.

James added eight carries for 31 yards, with four coming on the 49ers’ final five snaps in relief of starter Frank Gore (21 carries, 83 yards).

Defensive lineman Justin Smith did not return to the game after sustaining an elbow injury late in the third quarter. “I can’t comment on what it is, but we’ll go from there,” said Smith, adding that he’ll undergo an MRI exam Monday to determine the injury’s severity.

Smith walked to the 49ers locker room at the end of the third quarter for X-rays and was replaced by Ricky Jean Francois, who delivered a fourth-quarter sack.

Randy Moss returned to the site of his 2007 career resurrection and promptly produced a touchdown reception, something he did a league-record 23 times that season for the Patriots. Moss’ 24-yard touchdown catch gave the 49ers a 7-0 lead. It was his first touchdown in six games and his third this season.

Moss left without speaking to the media. Kaepernick tried to find Moss for more touchdowns as the game progressed, without success. Kaepernick’s only interception came on a 34-yard bomb to Moss that was nabbed by safety Devin McCourty. Kaepernick also targeted Moss in the end zone twice in the second quarter, the second attempt resulting in a pass-interference penalty on Moss. Moss was making his second start of the season, as Mario Manningham sat out a second straight game with a shoulder injury.

Moss’ first-quarter touchdown catch gave him 15,220 receiving yards in his career, surpassing Isaac Bruce (15,208) for third-most in NFL history. It also marked Moss’ 157th career touchdown, moving him past Terrell Owens for fourth-most all-time.

Nearly half of NBC’s first-quarter broadcast was pre-empted by President Barack Obama’s address about Friday’s school shooting in Newtown, Conn., which is a 2½-hour drive southwest of Gillette Stadium. To honor the victims, a pregame moment of silence was held while 26 flares were sent into the rainy sky.

For the third straight game, Frank Gore scored a touchdown, this one coming when he picked up Kaepernick’s fumble and ran it in in the third quarter.

Cornerback Carlos Rogers produced his first interception of the season, and he returned it 53 yards to the Patriots’ 5-yard line, where Tom Brady tackled him. The 49ers turned the ball back over two plays later on a Delanie Walker fumble.

Aldon Smith went without a sack for the first time in eight games, leaving him tied for the league lead with the Houston Texans’ J.J. Watt at 19½ sacks apiece. “Yeah it was frustrating, but other people were getting sacks and I was excited about that,” Smith said.

Brady set a career-high with 65 pass attempts, which were the seventh-most in NFL history and set a Patriots record for a non-overtime game. His 443 yards passing were his second-most.

Brady, a San Mateo native, threw a lone touchdown pass to extend his streak of 46 consecutive games with at least one. He eclipsed the 4,000-yard passing mark in a season for the fifth time in his career, joining only four others to do so: Dan Marino, Brett Favre, Drew Brees and Peyton Manning.

Brady threw multiple interceptions in a game for only the second time this season, having had two passes intercepted in an Oct. 14 loss at Seattle.

Ray McDonald, who entered Sunday’s game with only a half-sack, recorded two sacks of Brady.

Left guard Mike Iupati briefly left the game with a right-shoulder injury, and backup linebacker Clark Haggans did not return after sustaining a shoulder injury.

The Patriots were 0 for 7 on third-down attempts in the first half and finished 2 of 15.

Andy Lee produced a season-high net average of 54.0 yards on five punts, including three that pinned the Patriots’ inside their 20-yard line.

With third-stringer Scott Tolzien suiting up, the 49ers had all three quarterbacks active for only the second time this season.

Linebacker Tavares Gooden, who leads the 49ers with 13 special-teams tackles, was inactive because of injured ribs. Also out were safety Trenton Robinson, running back Jewel Hampton, guard Joe Looney and nose tackle Ian Williams.

Patriots tight end Rob Gronkowski missed his fourth straight game because of a broken forearm. Aaron Hernandez again started in his place. Also down for the Patriots were safety Derrick Martin, linebacker Tracy White, offensive lineman Markus Zusevics, defensive end Jake Bequette and defensive lineman Ron Brace.

In a video clip recorded by a student, a psychology instructor at Orange Coast College told her class that the election of Donald Trump was “an act of terrorism” – prompting an official complaint from the school’s Republican Club.