Sharapova famously won Wimbledon aged 17 in 2004, but she has struggled to emulate that feat for much of the last decade and this was another dispiriting experience for the Russian as the ninth seed sealed a stunning Centre Court triumph on her seventh match point.
The world number five arrived at the All England Club fresh from her second Roland Garros title, but she has now failed to make it past the last 16 in seven of her last eight appearances at Wimbledon.
"Every single set was so close so I'm just happy that I won against Maria. She's a great player," said Kerber after her second win in six matches against the Russian.
"I'm so happy to be in the quarters now. I had it before the match in my mind that the last few Grand Slams I lost in the fourth round.
More From This Section
"When I had the three match points in a row and it was deuce, I just tried to focus on myself and say 'believe in your game'. At the end it worked."
While Sharapova was bowing out, Safarova cruised into her first Grand Slam semi-final as the Czech 23rd seed thrashed Russia's Ekaterina Makarova 6-3, 6-1.
Safarova was playing in her first quarter-final at the majors since the 2007 Australian Open and showed no signs of being overawed in a ruthless 57-minute rout of the 22nd seed on Court One.