Sharapova had not played since the end of January after taking time out to recover from a shoulder injury and her lack of sharpness was exposed by Kerber, who cruised into the quarter-finals.
Kerber will now face either Spaniard Paula Badosa Gibert or France's Caroline Garcia, who play later on Thursday, for a spot in the last four.
Sharapova had registered an impressive opening victory over Viktoria Kuzmova on Tuesday but Kerber was always going to offer a sterner test of the five-time major champion's form and fitness.
Facing the tournament's top seed at this stage is the price Sharapova has to pay now for her lowly world ranking of 85 and she could well be dealt a similarly tough draw at Wimbledon, which starts in less than a fortnight's time.
Kerber, meanwhile, has endured a rather disappointing first half of the season herself, having crashed out in the first round at the French Open last month, after losing in the last eight in Australia in January.
But overcoming an awkward early meeting with Sharapova will represent a timely boost of morale for the German, who won Wimbledon last year and will be one of the favourites again at the All England Club.
Belinda Bencic, whom Kerber beat en route to the title 11 months ago, is a potential semi-final opponent in Mallorca, after the Swiss came from a set down to beat America's Shelby Rogers.
Rogers claimed the first set but retired injured after Bencic levelled up and led in the decider, the match ending at 5-7, 6-3 3-1.
Bencic will now play another American in the quarters, teenager Amanda Anisimova, who defeated France's Alize Cornet 6-2, 6-4.
Results from the WTA tournament in Mallorca on Thursday (x denotes seeding):
Angelique Kerber (GER x1) bt Maria Sharapova (RUS) 6-2, 6-3
Belinda Bencic (SUI x3) bt Shelby Rogers (USA) 5-7, 6-3, 3-1 -- retired
Amanda Anisimova (USA x5) bt Alize Cornet (FRA) 6-2, 6-4