TORONTO, Canada - No.16 seed Anett Kontaveit kicked off her North American Summer Hardcourt Swing with a titanic win over former World No.1 Maria Sharapova, rallying from a set and a break down to defeat the Russian wildcard, 4-6, 6-3, 6-4 at the Rogers Cup.

GALLERY: From Dementieva to Halep - A Decade of Rogers Cup Champions

"It was a super close match, and I really felt the support of the crowd in the third set and in the end," Kontaveit said during her on-court interview, saluting the crowd.

Playing her first match since retiring from the first round of Wimbledon, Sharapova appeared on course for just her fourth win since January as injuries have curtailed her 2019 season, but Kontaveit came through in dramatic style, winning after two hours and 41 minutes on Center Court.

"I'm still building the confidence and my form, and that's something that's just going to come with time and with match play," Sharapova said. "Unfortunately, I just haven't had that yet, so will just hopefully try to build on it.

"There's never the perfect scenario. I'm going to be coming up against tough players, long matches, and there are always going to be tests, and I always have to play my best tennis no matter who I play, so it will just take time to build that confidence again, because I have struggled with it for a long time."

A finalist in Toronto back in 2009, Sharapova, who spent the early part of the summer training with Riccardo Piatti, showed glimpses of that form early on as she broke Kontaveit to start the match, but the Estonian appeared determined to battle from first ball - perhaps to avenge their only previous encounter in Stuttgart back in 2017.

Kontaveit is in the midst of a solid season, having reaching the semifinals and the finals of the Miami Open and Porsche Tennis Grand Prix, and promptly broke back, but it was Sharapova who stayed strong to capture the opening set - striking eight winners and saving a break point as she served it out.

"In the first set, I felt like I had some opportunities and I just didn't use them," Kontaveit explained after the match. "I think I started serving better in the second set and that definitely, definitely helped. You don't want to be hitting second serves against Maria."

Down a break early in the second set, Kontaveit again leveled the set and saved five break points in the following game - three in a row from 0-40 down - to gain some momentum, breaking Sharapova once more and leveling the set at love.

It all came down to an epic ninth game in the decider, with Sharapova serving through nine deuces for nearly 20 minutes. Though the Russian held seven game points, it was Kontaveit who proved more clutch when it counted, converting her third break point opportunity of the battle.

"I was just trying to take it point by point and not think about the score that much. It worked in the end!"

With the finish line in sight, Kontaveit held firm, securing victory on her first match point.

As if to illustrate just how close the match was, Kontaveit struck just one more winner (26 to 25) and one less unforced error (35 to 36) than Sharapova, converting four of 12 break point opportunities and winning just eight more total points - 108 to 100.

"I'm definitely really happy with the win and am excited to be moving on. She's a great competitor, and so it's definitely a really good win."

It's unlikely to get any easier for the Estonian No.1, who plays the winner of another intriguing first round clash between five-time Wimbledon champion Venus Williams and former World No.6 Carla Suárez Navarro - with another former World No.1, Karolina Pliskova, looming in their section.

"It will be tough either way. I've played them both. They have very different game styles. We'll see what happens tomorrow when they're playing, and I think we can talk about the next match when they're finished, when they're finished playing each other."