DETROIT (AP) — The Detroit Lions are playing winning football right now. It's too late for it to matter, and that part is frustrating for Matthew Stafford and company.
Stafford threw for two touchdowns, including one to Calvin Johnson early in the fourth quarter, and Detroit took advantage of several mistakes by the San Francisco 49ers in a 32-17 victory Sunday.
The Lions (6-9) have won five of their last seven games, perhaps giving coach Jim Caldwell a chance to keep his job for a third season.
"It's a sick feeling because we understood how good we were back in training camp, but we took too long to show it," defensive end Darryl Tapp said. "We dug too big of a hole starting at 1-7, but we are working toward our future and hopefully coach Caldwell is a part of it."
Caldwell, perhaps coaching the Lions for the last time at home, called for a fake punt and the gamble paid off. Isa Abdul-Quddus took a direct snap to the upback and converted a fourth-and-1 from the Detroit 35. Stafford went on to throw a 29-yard pass to TJ Jones for his first TD reception, putting the Lions up 10-7 early in the second quarter.
The second-year coach, who is guaranteed to have a winning record with the team even after next week's finale at Chicago, also challenged a spot at the end of the third quarter to help set up Detroit with a first down, leading to Johnson's 1-yard TD catch.
Caldwell dodged questions about his future and deflected credit for his team's recent success.
"This is a group of very motivated, very competitive NFL players who want to win every game they play," he said. "I'm very happy with the way they have fought down the stretch."
The 49ers (4-11) have lost three straight and five of six under first-year coach Jim Tomsula.
Stafford's TD pass to Johnson gave Detroit a 12-point lead one play after Tramaine Brock was called for pass interference in the end zone. During the drive, the 49ers were flagged for being offside or in the neutral zone for the seventh time to set a single-game high by an NFL team this year, according to STATS.
"That's shooting ourselves in the foot," 49ers defensive end Arik Armstead said. "We beat ourselves."
San Francisco turned the ball over on downs on its next two possessions.
The 49ers became the first team to have six offside or neutral-zone penalties in the first half since 1993, when the Houston Oilers did it against New Orleans, according to STATS. On special teams, they allowed Detroit to convert a fake punt, missed a field goal and negated a pair of 30-plus yard returns in the closely contested first half with penalties. San Francisco was flagged 11 times for the second straight week.
"For the life of me, I can't give you an excuse," Tomsula said.
Blaine Gabbert threw for two TDs, both of which gave San Francisco a lead in the first half, but his fumble let the Lions take the lead for good. Gabbert finished 22 of 33 for 225 yards.
Joique Bell's 1-yard run midway through the second quarter gave Detroit a 17-14 lead one play after Gabbert lost the ball on a sack.
Stafford was 29 of 37 for 302 yards. Johnson, possibly playing his last home game with the Lions because they may cut him to manage their salary cap, had six receptions for 77 yards.
San Francisco's Anquan Boldin became the 13th NFL player with 1,000 career receptions on the first play of the game.
"At this point, it doesn't mean much," he said. "I'd much rather take the win."
Boldin caught all five of the passes thrown his way for 27 yards in the first quarter and wasn't targeted by Gabbert the rest of the game.
DuJuan Harris, signed by San Francisco on Tuesday off Baltimore's practice squad, ran for a career-high 73 yards while replacing injured running back Shaun Draughn. He helped the 49ers to a relatively successful first half in which they tied a season high for points by halftime and scored a TD on offense in the opening quarter for the first time.
Harris had 74 yards on nine carries in the first half when the 49ers trailed 20-17, and then carried the ball just two more times in the second half.
"We got up on them, so they had to throw more," Tapp said. "When you make teams play one-dimensional football, you give yourself a better shot to win."
NOTES: Detroit's Matt Prater made all four of his attempted field goals, one in each quarter. ... San Francisco DT Quinton Dial left with a back strain.
AP NFL website: www.pro32.ap.org and http://twitter.com/AP\_NFL
Follow Larry Lage at http://www.twitter.com/larrylage
Copyright © The Associated Press. All rights reserved. This material may not be published, broadcast, rewritten or redistributed.