Swiatek had won six straight tournaments, including her second French Open title, but found Cornet, the world No. 37, to be too good as she suffered only her fourth defeat of the year.
Swiatek's win streak was the longest since Martina Hingis also won 37 matches in a row in 1997.
"I know I didn't play good tennis. I was pretty confused about my tactics,'' said Swiatek, who has never advanced past the fourth round at the All England Club. "For sure, it wasn't a good performance for me.''
It's the second time Cornet has caused a major shock at Wimbledon, having knocked out then-world No 1 Serena Williams at the same stage in 2014.
"I have no words right now," said Cornet, who is playing in her 2nd consecutive major, which is tied for tops among women all-time. "It reminds me of the time I beat Serena on the same court. I think this court [No. 1] is a lucky charm for me.
"I think this kind of match is what I'm living for. I knew I could do it. Somehow I had this belief. I thought if there is any way I can beat her, it's now."
Cornet, who reached her first grand slam quarterfinal at the Australian Open in January, hit 16 winners and made just seven unforced errors in a near flawless performance. Swiatek, meanwhile, had 33 unforced errors and 21 winners.
Cornet, 32, broke twice as she raced to a 3-0 lead -- of her first 14 points, nine came via unforced errors off the racket of the 21-year-old player from Poland, and only one came via a winner produced by Cornet herself.
"Usually when I'm coming back, I have some kind of a plan and I know what to change," Swiatek said. "Here I didn't know what to change. I was confused. On grass court everything happens so quickly.
"... So here I didn't have any idea. I didn't tank it, but I just didn't know what to do."
Though Swiatek settled down, she could get only one of the breaks back as Cornet took the first set.
It looked as if Swiatek was back when she broke to lead 2-0 and was 40-15 up on her serve, only to lose six straight games as Cornet clinched another big upset.
Cornet will next face unseeded Ajla Tomljanovic in the fourth round.
"I'm like good wine," Cornet said. "Good wine always ages well.''
The Associated Press contributed to this report.