Sharapova won 3-6 6-3 6-4 to reach the semi-finals at Flushing Meadows for the first time in six years.
The Russian fought back after losing the rain-interrupted first set and opening service game in the second set to win a two-and-a-half-hour match that began on Tuesday afternoon and took 24 hours to complete.
"I tried not to think about it too much," said Sharapova. "It was good to have that period of time just to get a good night's sleep and come back."
Frenchwoman Bartoli, a Wimbledon finalist five years ago seeded 11 in New York, threatened to pull off the upset when she led 4-0 overnight and wrapped up the first set.
Sharapova, who won the US Open in 2006 and completed her Grand Slam collection by winning the French Open in June, was initially struggling with her own serve in blustery conditions at Flushing Meadows.
The world number three dropped serve at the start of the second set when she made three double faults but regained her composure and recovered to force a deciding third set.
The pair traded breaks early in third set before Sharapova, who hit an impressive 44 winners in the match, got the decisive break in the ninth game then served out victory.
Sharapova has not been beaten this year in any match that has gone three sets.
"It's not always a good feeling to come into a match to knowing that you're down 0-4," she said. "It's like you're going to try to win that set, but if you don't you're down 0-1.
"It's so long since I've been back to this stage at the US Open. A little bit of luck always helps."
She will now play world number one Victoria Azarenka of Belarus in Friday's semi-finals.
"She beat me in Australia quite easily and I would love to get my revenge at a Grand Slam," Sharapova said.
Serena Williams, brimming with confidence and self-belief with every match she plays, stormed into the semis with a 6-1 6-3 demolition of Ana Ivanovic.
The last American left in the tournament after Andy Roddick was sent into retirement by Juan Martin del Potro, Williams was at her irresistible best and steamrolled Serbian Ivanovic in less than an hour.
Williams has won the US Open three times and made the semi-finals in each of her last four appearances at Flushing Meadows but has not lifted the trophy since 2008.
She has been in great form over the past few months, clinching her 14th Grand Slam title at Wimbledon then winning the singles and doubles gold medals at the London Olympics.
By her own standards, she made a slow start to the US Open but said she was hitting her peak at the right time.
"I feel like I'm going to get more focused and serious and start playing Serena tennis in the next couple of rounds, if I get to play two rounds. That's my goal," she said.
"I didn't think I came into this tournament playing my best, but I definitely played better in the last two matches."
Williams plays Italian Sara Errani in Friday's semi-finals, a player she has beaten in each of their three previous meetings.
"She (Errani) is playing well," said Williams. "She made the final at Roland Garros and now semis here, potential finals, so I can't underestimate her.
"It's not by luck she's been doing so well. We will have to see."
Former world number one Ivanovic was appearing in her first Grand Slam quarter-final since winning the French Open in 2008.
She conceded Williams had been too strong but said she was buoyed by her own improved performance.
"Overall I'm very satisfied. I played some really good tennis to get into this position," she said. "Even tonight I felt like I was striking the ball so nicely on both sides.
"That's something that I worked hard for. I think it's a big step for me to reach quarter-final. It's a confidence boost."
Errani beat her best friend and doubles partner Roberta Vinci 6-2 6-4 to reach the semi-finals of the US Open for the first time.
The two Italians, who teamed up to win the French Open doubles title in June, briefly put aside their friendship as they traded blows for a place in the last four.
"It was very difficult match, a quarter-final with your best friend, of course, is difficult," said Errani.
"We know each other very well, we've played together many times so it was strange to see her on the other side of the net.
"Normally, when you walk on the court, we go together, we speak. This was strange."
The diminutive Errani was the favourite to win after making the French Open singles final this year and proved too strong for her countrywoman, landing an impressive 85 per cent of her first serves to wrap up victory in 72 minutes.
Errani had never made it past the third round of the US Open before this year.
"It's the best year of my life," said Errani. "I'm playing very good and my ranking is very high.
"Two or three years ago, it was a bit difficult going on the court and feeling that I can win with the best players.
"But now I feel a bit different...I feel that I can fight with everybody."
The pair, who have been dining together during the tournament, embraced each other at the end and have not seen the last of each other this week.
They are already through to the semi-finals of the doubles and the second seeds are lurking as the pair to beat after the early exit of the Williams sisters, Venus and Serena, and the top seeds, Liezel Huber and Lisa Raymond.
Regardless of whether they win or not, Errani will take over as the number one doubles player in the world when the new rankings are released next week. Vinci will be ranked second.
"Being number one in the world in doubles with your best friend is amazing, maybe the best," said Errani.