The 31-year-old Scot fluked a treble into the middle pocket to seal a 5-4 win in the most dramatic fashion, booking him a semi-final place against Stephen Lee, who beat reigning champion Judd Trump 5-3.
Maguire, who won this tournament in 2008 and was the 2004 UK champion, opened up a 2-0 lead with breaks of 76 and 57 enough to subdue O'Sullivan early on.
The three-time world champion showed his class however, with a break of 88 enough to win the third frame and a 60 sufficient to level the match after Maguire missed a red into the middle pocket.
A break of 79 restored the Scot's lead but a missed blue in frame six prompted a spectacular 102 response from O'Sullivan, who concluded the frame by blasting in the final black.
Maguire moved in front again but a 48 from O'Sullivan forced the decider. Maguire went on an early run to 29 before overstretching for a black, before a 41 put O'Sullivan in the driving seat.
Maguire could not get position from the final red to take on the black or pink, so a re-spot was the best he could hope for and after clearing the colours, he rode his luck to see out the match.
Afterwards, Maguire told worldsnooker.com: "I'm obviously pleased with how it ended. I thought I threw a few frames away early on in the match. I thought I could have won a little bit more comfortably but it's never easy against Ronnie.
"All the players know that if you let him in for one chance then usually he clears up. So lucky enough for me in the last frame there he missed the last red and I managed to nick it in the end.
O'Sullivan gave all the credit to Maguire after exciting the tournament.
"He's been a solid player all year, he's a top player and you've got to give credit to Stephen because he hung in well there and he made a clearance at the end to get us to the re-spot as well," he said.
"It's just the way it goes. It's one of those shots he fancies, there's a good chance you're going to get those cross doubles. I didn't think he was going for it because he was hitting it thin, I thought he was playing safe.
"But then he hit it quite hard and I thought he'd missed it, obviously it went over the second time and went in but that's the type of shot you can get. It's not a hard double but obviously it was an all-or-nothing shot and it went in for him."
Trowbridge cueman Lee secured a fourth ranking event semi-final appearance out of the last five with his triumph over Trump.
Trump took a 2-0 lead with an impressive 92 break but Lee stormed back to lead 4-2, with a stunning 113 bringing him level at 2-2.
Last year's World Championship finalist Trump cleared to the pink to win frame seven but a break of 96 sealed it for Lee.
Trump quickly shrugged off his disappointment to turn his attention to the upcoming World Championship.
"I started off okay and then Stephen played well to get back to 2-2, after that I really struggled with it," he said. "I should've won a big frame to go 3-3 but I missed an easy pink.
"I won't really take too much notice of it. It's a lot harder to play out here with the time difference so I won't really take too much notice. I'm just looking forward to the World Championship and hopefully I can have a good run there."
In the evening session, home favourite Ding Junhui comfortably beat Ali Carter 5-2 to advance while Peter Ebdon had to battle his way to a 5-3 win over Neil Robertson to book his own place in the semis.