DETROIT — Carson Wentz was having another splendid game when the Philadelphia Eagles finally turned the ball over a couple times.

Those giveaways led directly to their first loss of the season.

Ryan Mathews fumbled on a third-down run near midfield, setting up Detroit’s winning field goal Sunday in its 24-23 victory over the Eagles. Wentz had one last chance to rally his team after the Lions went ahead, but he immediately attempted a deep pass that was intercepted by Darius Slay with 1:17 remaining.

Wentz went 25 of 33 for 238 yards and two touchdowns and helped the Eagles come back from a 21-7 second-quarter deficit. Slay said he was skeptical coming into the game about the hype surrounding the rookie, but he called him “the real deal” afterward.

“He shouldn’t have thrown that last pass, though,” Slay said. “I knew I had that ball covered, and so when I saw the ball in the air, I was like, ‘Time for your first pick, young man.’”

Wentz hadn’t been intercepted at all this season. In fact, the Eagles hadn’t turned the ball over a single time until the final minutes against the Lions.

With Philadelphia clinging to a 23-21 lead and facing third-and-2 from its own 45-yard line, the Eagles gave the ball to Mathews, hoping he could pick up the first down and put the game out of reach. He was stopped well behind the line of scrimmage by Slay, and the ball came loose. Detroit’s Tyrunn Walker recovered near the sideline, and the Lions (2-3) took over with 2:34 remaining.

“We knew they were going to run the ball there, so I was extra aggressive,” Slay said. “I knew he had been holding the ball away from his body, so I thought there might be a chance, but I didn’t even know what had happened. I was celebrating getting the stop and forcing a fourth down, and then I heard the guys yelling that we had the ball.”

Matt Prater’s 29-yard field goal with 1:28 to play put Detroit ahead, but the Eagles still had plenty of time and only needed a field goal of their own. After a touchback on the kickoff, Wentz threw deep for Nelson Agholor on the very first play, and Slay was able to run under the ball and intercept it.

“It was kind of an alert I had breaking the huddle,” Wentz said. “You always want to get the drive started on the right foot, especially in those situations, but the coverage kind of dictated that. We didn’t make the play, they made a great play.”

Before the season, Slay signed a four-year extension worth about $50 million, a deal that lasts through 2020. His first interception of the season was a big one.

“It wasn’t a perfect throw, obviously,” Wentz said. “He made a great play — hats off to him.”

It was the last big mistake for the Eagles (3-1) on a day they committed 14 penalties for 111 yards. The Lions were flagged only twice.

The fumble by Mathews was Philadelphia’s fifth of the season — but the first time the Eagles lost the ball. They almost retained possession because the ball was near the sideline and could have easily bounced out of bounds, but this time, the break went to the opponent.

“We needed that,” Lions receiver Golden Tate said. “That was a big-time play right there. That’s something that we go into every game wanting — to get turnovers, interceptions or fumbles. However you get them, we need to get them, and that was just a key one.”