Raonic had a bye into the second round, and the loss puts him in danger of failing to qualify for next month's ATP tour finals in London. He blamed the defeat on illness.
''I was sick for the last 10 days, so I was in bed the whole time and I only was able to prepare the last two days,'' Raonic said.
Raonic, who currently holds the eighth and last qualifying place for the World Tour Finals, said ''there's not really that much of a heartbreak'' in exiting Moscow so early, since more points are on offer when the Paris Masters starts later this month.
The ninth-ranked Canadian struggled with his usually powerful and accurate serve, winning only 40 percent of second-serve points.
For the 116th-ranked Berankis, it was his first career win against a Top-10 player. His reward is a quarterfinal against Spain's Roberto Bautista Agut, seeded fifth.
Earlier Thursday, last year's runner-up Mikhail Kukushkin knocked out fourth-seeded Fabio Fognini of Italy 6-4, 6-2.
Third-seeded Ernests Gulbis defeated Daniel Gimeno-Traver 6-3, 7-6 (3). Sixth seed Tommy Robredo beat Filip Krajinovic 6-3, 6-4 in 59 minutes. Robredo will play U.S. Open champion Marin Cilic, the second seed, in the quarterfinals.