Serving at 4-5 in the second set of a see-saw struggle, the third seed Sharapova saved three set points before winning the final three games to end the two hour, 29-minute battle.
"She had her chances to win that second set. Who knows what would have happened," said Sharapova, a four-times Miami finalist who has yet to win the tournament.
"I'm lucky to get to the next one and have a chance to be in the semis again ... the great thing is that I pulled through. I worked hard. I was steady, and I gave myself a chance to get here."
Errani had four service breaks against Sharapova, who committed 14 double faults. But the 25-year-old Italian was even more vulnerable to the big-hitting Sharapova, who broke serve six times.
Sharapova, bidding for a rare double following her win at Indian Wells earlier this month, will play 2008 runner-up Jelena Jankovic of Serbia in the semi-finals.
The Russian is seeking a 29th career title in Florida. She has reached the final on four occasions in Miami, losing them all - to Kim Clijsters in 2005, Svetlana Kuznetsova in 2006, Victoria Azarenka in 2011 and Agnieszka Radwanska in 2012.
"I've been so close to winning," she said. "I would love to win this.
"I've been coming to this tournament since I was a little kid. It would mean a lot to win it."
Jankovic booked her place in the last four with a 6-4 6-7(6) 6-3 victory over 15th seed Roberta Vinci of Italy in the final women's match of the day on Stadium Court.
The Serb was made to battle hard, particularly during a second set tie-break which she edged by a fine margin to send the match into a decider.
The final set was slightly more comfortable for Jankovic, who broke twice before sealing victory in two-and-a-half hours.
The other semi-final features Serena Williams against Agnieszka Radwanska.
WTA Miami results
22-Jelena Jankovic (Serbia) beat 15-Roberta Vinci (Italy) 6-4 6-7(6) 6-3
3-Maria Sharapova (Russia) beat 8-Sara Errani (Italy) 7-5 7-5
- Sports & Recreation
- Jelena Jankovic