Matters went well for both players as each won to advance to Friday's quarterfinal round.
The Russian saved the first two breaks points, but Opelka hit a magical wide-angled volley in reply to Medvedev's down-the-line backhand to level the match.
Second-seeded Canadian Denis Shapovalov rolled to a 6-1, 6-4 win over qualifier Ilya Ivashka of Belarus and third-seeded Russian Andrey Rublev fought to a 4-6, 6-4, 7-5 victory over France's Ugo Humbert.
Britain's Cameron Norrie will face Andrey Rublev for a place in the semi-final.
Also, second-seeded Roberto Bautista Agut of Spain recorded a 6-4, 7-6 (5) victory over Gilles Simon of France; third-seeded Canadian Felix Auger-Aliassime was a 6-4, 6-1 victor over Swiss qualifier Henri Laaksonen; and Spain's Alejandro Davidovich Fokina registered a 3-6, 7-6 (3), 6-2 upset of eighth-seeded Marin Cilic of Croatia. Coric won 7 of his last 10 matches.
Opelka converted his third set point to break the top-seeded Medvedev in the final game in the second set, and then broke for a second time at 5-4 in the third to clinch the match.
Hard-serving American Reilly Opelka saved four break points in the final set before beating defending champion Daniil Medvedev 2-6, 5-7, 4-6 on Thursday to reach the quarterfinals of the St. Petersburg Open. The Croatian defeated Russian wild-card entry Roman Safiullin 6-3, 7-5 after coming back from 3-1 down in the second set.
During an on-court interview in the spotlight afterward, Opelka said, "It is always a tough match, playing one of the best players in the world in general, but especially at [his] home. It's a great win for me", said Opelka.
"It was ugly for the first set-and-a-half. Daniil is an absolute nightmare to play, especially for a guy like me because he just runs every ball down".
What surface is Reilly Opelka vs Borna Coric being played on? .