Italian qualifier Mattia Bellucci defeated former world number one Daniil Medvedev in three sets to reach the Rotterdam ATP quarterfinals.