The 16-year-old Russian, who has been a crowd favourite on her debut at the All England Club, looked set to become the youngest player since Anna Kournikova in 1997 to make the quarter-finals here when she led by a set and 4-1.
But Keys fought back and Andreeva was given her first warning by umpire Louise Azemar Engzell after flinging her racket across the grass when she lost the second-set tie-break.
She then appeared to slam her racket to the ground when Keys forced deuce at 2-5 in the deciding set, earning a second warning and an automatic point penalty, which gave her opponent a match point.
Andreeva argued her case with Azemar Engzell, saying: “Do you understand what you are doing? I didn’t throw the racket. I slid. It’s the wrong decision. I slid and then I fell.”
But the decision stood and Keys won the next point to clinch a 3-6 7-6 (4) 6-2 victory, with Andreeva heading to the net to briefly shake hands with her opponent but walking straight past the umpire.
The Russian said afterwards: “She’s the umpire. She’s the one who makes the decision. But, honestly, I didn’t have any intention to throw the racket. I slid. I thought that I will fall forward. Maybe it did look like I threw the racket.”
She was unrepentant about not shaking Azemar Engzell’s hand, adding: “For me, she didn’t do a right decision. That’s why I didn’t want to shake hands with her.”
Andreeva had feared being defaulted after whacking a ball angrily into the crowd at the French Open and teenage petulance is something she will clearly need to grow out of, but there is no doubt she is a special talent.
She is working through the issue by talking to herself in bed every night, and has taken encouragement from the way the likes of Roger Federer overcame teenage tantrums.
“I knew that Federer was struggling with emotions when he was teenager,” she said. “Actually when I was younger, I saw that, ‘Well, he was struggling also. I’m not the only one who also struggles’.
“I thought that I just need to wait a little bit and it will go away. But it doesn’t work like this. You just have to work on yourself. The faster you’ll do it, then the results will come also faster, I think. I started to work on myself just with myself. I think it works pretty good now.”
Andreeva had not played on grass until the qualifying tournament two weeks ago but she has learned quickly on the surface and is already an impressively complete player.
Keys, who was looking to make the quarter-finals here for the first time in eight years, helped her young opponent with a slew of errors but she changed her tactics midway through the second set to follow her big groundstrokes to the net and even broke serve with a left-handed forehand winner.
By the time the second-set tie-break came around, it was Keys who had the momentum, and the American kept her young opponent at arm’s length during the decider to set up a last-eight clash with second seed Aryna Sabalenka.
Keys, who won the warm-up tournament in Eastbourne, admitted she felt the pressure of the occasion, saying: “It’s tough being on the other side of the net of a 16-year-old who is really playing with nothing to lose and you’re the one that’s supposed to beat her.
“I think she’s a really great player on top of all of that. I think she moves incredibly well. I was very impressed with her serve. Overall I think she has a very solid game. It’s obviously going to improve with time.”
Now 28, Keys was once a teenage prodigy, and, asked what advice she would give Andreeva, she said: “I would say ignore everyone, and everything that they say, unless you actually care about their opinion.”
Andreeva is limited in the amount of senior tournaments she can play because of her age but she will be ranked close to the top 60 next week, which is more than high enough for entry to the US Open.
She relished her Wimbledon debut, saying: “For me, it was an amazing experience. Amazing matches I’ve played here. First time on grass. I’m happy with my result, but also at the same time I’m sad and disappointed a little bit. Next year I hope, and I will do my best, to do better.”