The 22-year-old Khachanov was in devastating form at the start as he dropped only two points in his first four service games. After bagging the first set tiebreak, he then unexpectedly lost his way.
The 53rd-ranked Berrettini fired down nine aces en route to booking a place in the quarter-finals.
"It was a very difficult first set, I didn't play so well," said Berrettini. "But then I improved my performance in the second set and I think I played very well in the third."
Sixth seed Fernando Verdasco set up a second-round showdown with Romanian Marius Copil, who outclassed Swiss Stan Wawrinka in the opening round. Verdasco secured a comfortable 6-2 6-1 victory over Bulgarian qualifier Alexandar Lazarov.
"I played very well today, very solid," the 35-year-old Verdasco said.
Fourth seed Roberto Bautista Agut, who won the tournament in 2016, came back from a set down to beat Australian Matthew Ebden 3-6 6-3 6-2 in the last 16, while Hungarian Marton Fucsovics upset Italian eighth seed Andreas Seppi 6-2 7-6(2) in a first round tussle.
World number 38 Klizan clinched a 6-0 3-6 6-2 victory over the 27-year-old Bosnian, who lifted the trophy in Armeets Arena last year as a qualifier, winning seven matches in a week.