DETROIT — Despite possessing one of the league's top offensive units, the Kansas City Chiefs had to survive themselves Sunday against the Detroit Lions.

The Chiefs overcame a sluggish outing from quarterback Patrick Mahomes, a case of turnovers on offense and a defense that gave up its share of big plays against a worthy Lions team.

Ultimately, the Chiefs dodged a late Detroit rally and put everything together when it mattered late in the final quarter to secure a 34-30 victory at Ford Field and remain unbeaten at 4-0.

"We were all playing hard and this offense had never played like that," Chiefs wide receiver Sammy Watkins said. "We were all looking at each other, like, 'What the freak is going on?'

"But the resiliency of this team, the coaches, we kept fighting every play, every down. We scratched, we clawed and we came out with the win, and it was a blessing."

Down 30-27 with a little more than two minutes remaining, Mahomes marched the Chiefs down the field on a 13-play, 79-yard drive, connecting with five different receivers.

Darrel Williams finished the drive with a game-winning 1-yard touchdown run. Mahomes helped keep the series alive with a 15-yard scramble on a fourth-and-8 play.

The victory was sweet given the Chiefs' early issues on both sides of the ball.

"We just found ways to pick each other up whenever the other was struggling," Mahomes said. "In this league, it's not always going to be pretty. It's not always going to be 50 points and three-touchdown wins.

"You're going to have to find a way to win these games against great teams. So for us, we know that this win, of not playing our best football and finding a way to win, is going to help us tremendously as we get to the end of the season."

In a matchup that had its share of ups and downs for both teams, the Chiefs' defense came up big in the second half, especially midway through the third quarter after the offense turned the ball over.

The Lions were at the Chiefs' 1-yard line when running back Kerryon Johnson fumbled at the goal line. Chiefs defensive tackle Xavier Williams stripped the ball.

Cornerback Bashuad Breeland scooped it up and returned it 100 yards for a touchdown. The officials did not blow a whistle, and the play was upheld after review to give the Chiefs a 20-13 lead.

Detroit answered after recovering a Watkins fumble. Lions quarterback Matthew Stafford found wide receiver Kenny Golladay for a 9-yard touchdown pass to give the hosts a short-lived 23-20 lead.

The third quarter produced five turnovers, three by the Chiefs and two by the Lions. Their five combined fumbles were the most in the NFL in a single quarter since 1991.

Detroit went ahead again late in the fourth quarter when Stafford connected with Golladay for a 6-yard score to give the Lions a 30-27 lead at the 2:26 mark.

Meanwhile, Mahomes didn't get going until the fourth quarter.

The league's reigning MVP was surprisingly off on numerous deep throws early and often in the game against a Lions secondary that was playing without two-time Pro Bowl cornerback Darius Slay (inactive with a hamstring injury). The Lions also lost safety Quandre Diggs in the first half to a hamstring injury.

But Mahomes was good enough when he needed to be and finished the game completing 24 of 42 passes for 315 yards, 105 coming in the final period.

He also hurt the Lions with his legs, rushing for 54 yards on six carries.

Mahomes didn't throw a touchdown pass, marking the first time since Oct. 7, 2018 that the signal-caller didn't connect in the end zone. Mahomes' 7.5 yards per completed pass Sunday was lower than the 10.5 yards per completion with which he entered the game.

But the absence of individual video game-like statistics didn't bother the star quarterback.

"It's not always about the touchdowns and the yards — it's about finding a way to win," Mahomes said. "If that was running for the first down, if that was handing the ball off when have my running backs work for me, I mean, I'm going to do that. If you want to be great as a team, as a player, it's how you win the game.

With the passing game struggling to get going, running back LeSean McCoy helped pick up the slack with 56 yards rushing and a touchdown on 11 carries.

McCoy's 39-yard run in the second quarter helped set the stage for the Chiefs' first touchdown, which came on his 1-yard plunge to tie the score at 10.

Williams chipped in 13 yards rushing and two touchdowns on eight carries.

The Chiefs' defense was plagued by lapses early in the first quarter, surrendering two separate plays of 33 yards on passes from Stafford to wide receivers Golladay and Marvin Jones Jr. The chunk plays helped the Lions build a 10-3 lead by the end of the first period.

Kansas City, which entered the game ranked 27th in the league against the run, also had problems with Lions running back Kerryon Johnson, who finished the game with 125 yards on 26 carries, averaging 4.8 yards per attempt.

The Lions running back entered the game averaging a paltry 2.6 yards per carry but found the going easy against one of the league's worst run defenses.

But the Chiefs' defense found other ways to affect the game, totaling four sacks, five quarterback hits and forcing two fumbles.

"I was proud of our defensive front for the four sacks," Chiefs coach Andy Reid said. "This is a quarterback (Stafford) that hasn't been sacked at all this year. To have those sacks I thought was a big thing."

Defensive tackle Chris Jones spearheaded the defensive charge with two tackles — one for a loss — a sack, a quarterback hit and a forced fumble.

Sunday might have given the Chiefs a win and a feel-good moment of overcoming adversity on the road.

But they know there were plenty of lessons to apply before they host the Indianapolis Colts next weekend at Arrowhead Stadium.

"There's a lot of teachable tape," Watkins said. "We got to fix a lot of stuff, and get back to the same offense that we've been and the same defense that we've been, and come together as a whole collective and win the next game."