Barty had won 15 matches in a row dating back to the Italian Open in May and taking in her maiden grand slam singles title at the French Open and success on grass at the Nature Valley Classic in Birmingham that elevated her to the top of the rankings.
But she found grass-court specialist Riske too big an obstacle, the 55th-ranked American recovering from a set down to win 3-6 6-2 6-3.
It was the biggest victory of the 29-year-old's career and she will face Serena Williams on Tuesday in her first grand slam quarter-final.
Riske probably had not expected to be centre stage until after the Championships, when she will marry fiance Stephen Amritraj.
"I wish I could get married more often," said Riske with a grin. "Maybe we'll have to renew our vows because it's worked out well having that on the horizon. I'm looking forward to it so much.
"Everything is pretty much already in stone. I'm not really stressed about it. I haven't been stressed about it really from the beginning probably because my fiance has been doing all the work.
"We both love Wimbledon equally as much. We love London. We would love to live here, love to be a member of the All England Tennis Club. Just throwing it out there.
"All the people here have been special. (Chairman) Phil Brook, from the first time I came to Wimbledon, he's remembered my name. I think it's something that is really important for someone like me who wasn't top 10, top 20."
Riske has a remarkable record on grass. The season is only five weeks long yet her first 13 tour level wins all came on grass and she arrived at the All England Club with trophies in her bag from Surbiton and 's-Hertogenbosch.
She had not managed to translate that to a standout Wimbledon run until this year, though, with her scalps also including Donna Vekic and Belinda Bencic.
"I'm so incredibly excited," Riske beamed. "The fact that it's at Wimbledon, my favourite grand slam, the place that I had always dreamed to be in the last eight club of – they can't kick me out now, I'm here to stay. I am just over the moon."
Barty had not lost a set since the semi-finals of the French Open a month ago and she began with a perfect game of four straight aces.
But that became her Achilles heel, with her first-serve percentage dropping to 40 in the second set.
Riske took the momentum and ran with it, breaking the Barty serve in the eighth game of the decider.
The Australian reflected afterwards: "I think I started well. I was sticking to how I wanted to play. Then in the second set, I think my serve let me down. I let Alison get back into the match too many times, having looks at second serves.
"Overall I didn't play a poor match. When I needed to, when the big moments were there, Alison played better today. Tough one to swallow but I lost to a better player."
Barty had been hoping to join Williams as the only active player to win the French Open and Wimbledon back to back, but she was not too downbeat.
She said: "It's disappointing right now. Give me an hour or so, we'll be all good. The sun's still going to come up tomorrow.
"It's been an incredible few months. New ground for me here at Wimbledon. This is the best we've done. I'm very proud of what we've been able to achieve."
Barty is at least guaranteed to hold onto top spot in the rankings after Karolina Pliskova also lost in the fourth round.
While she heads home for a rest, Riske will try to continue her giant-killing run against the biggest of them all.
"I think it's super exciting," she said. "I played doubles with Serena, but never played against her. I'm ready for a war."