SANTA CLARA, Calif. -- The key for the San Francisco 49ers' defense in slowing the Philadelphia Eagles' high powered offense?

“To tackle No. 25,” said 49ers free safety Eric Reid, referring to Eagles All-Pro running back LeSean McCoy. “Which, we did.”

And then some.

The Niners held LeSean McCoy to just 17 yards on 10 carries. AP Photo/Ben Margot

The 49ers limited McCoy, who led the NFL in rushing last season with 1,607 yards, to a mere 17 yards on 10 carries. Darren Sproles carried the ball once for 4 yards, and quarterback Nick Foles was credited with a 1-yard rush.

That’s it. The 49ers' defense, roundly and perhaps rightly criticized this week for having only four sacks and three interceptions through a 1-2 start, responded Sunday and led the Niners to a 26-21 victory by pitching a shutout.

The Eagles’ touchdowns came on a blocked punt return, an interception return and a punt return.

Until Philadelphia drove from their own 9-yard line to the 49ers’ 1-yard line with 2 minutes to play, the Eagles had not crossed midfield. And with the game on the line, the defense again answered, keeping the Eagles out of the end zone after they had first-and-goal from the 5.

“The defense turned in a real gem,” 49ers coach Jim Harbaugh said. “And they were getting off the field early in the possessions. The no-huddle attack, you don’t give them the first and second first down, the third first down. They were doing a heck of a job getting off [the field] between the first down and the second.”

And giving the Eagles no shot at establishing a running game.

NFL Nation: Week 4 Coverage • NY Giants at Washington

• Green Bay at Chicago

• Buffalo at Houston

• Tennessee at Indianapolis

• Carolina at Baltimore

• Detroit at NY Jets

• Tampa Bay at Pittsburgh

• Miami at Oakland

• Jacksonville at San Diego

• Atlanta at Minnesota

• Philadelphia at San Francisco

• New Orleans at Dallas

• New England at Kansas City

Of course, Philadelphia’s makeshift offense line -- left tackle Jason Peters was the only regular in his usual spot, and he went down for a bit before returning -- helped the Niners’ attack. As Eagles coach Chip Kelly said, the 49ers were able to affect his passing game with only a three-man rush, which then allowed San Francisco to stack the box against the running game.

“I’m embarrassed,” McCoy said, according to the Philadelphia Inquirer.

Per ESPN Stats & Information data, the Eagles had only 6 yards after contact on 12 rushes and did not have multiple yards after contact on any rush.

So how, exactly, were the 49ers able to make McCoy & Co. non-factors?

“The safeties and I were talking the whole game about different ways to make sure we kept LeSean in the box, because of the way he was bouncing outside,” he said. “He’s really good at doing that, so we really talked the whole game about making sure we had an edge set, and I think for the most part we did a pretty good job."

Added inside linebacker Patrick Willis: “They do a lot of uptempo, fast-tempo offense and all it takes is for one guy to be out of place and they’ll find it. I feel like today we did a great job of communicating and making sure we played our defense.”