Melbourne - Caroline Wozniacki had tears in her eyes as she kept alive her dreams of a triumphant farewell to tennis at the Australian Open on Wednesday.
The 29-year-old former world No 1 roared back in both sets to defeat 23rd-seeded Dayana Yastremska of Ukraine 7-5, 7-5.
Neil Diamond's hit "Sweet Caroline" rang around a blustery Margaret Court Arena after the Dane nailed her sixth match point to reach round three.
She plays Ons Jabeur of Tunisia on Friday.
"It's a little bit emotional for me," said Wozniacki, the 2018 Australian Open winner who announced in December that this would be her final tournament.
"The crowd really got behind me so that was so special. Thank you everyone for coming out today, it really means a lot to me," she added, fighting back tears.
The 19-year-old Yastremska, beaten by world number one Ashleigh Barty in last week's final in Adelaide, threatened to put a swift end to Wozniacki's career.
But having been 5-1 down in the first set, Wozniacki - who suffers with rheumatoid arthritis, which causes fatigue and joint pain - fought back to claim the set in 53 tough minutes.
Now ranked 36, having ended 2010 and 2011 at No in the world, Wozniacki was similarly quickly down 3-0 in the second set.
But once again she battled back to make it 4-4, then held her own serve to lead 5-4 and within touching distance of round three.
Yastremska then required a medical timeout for what appeared to be a left thigh problem, and returned to court with heavy strapping.
She saved five match points, but with the crowd firmly behind her, Wozniacki would not be denied at the sixth attempt, the young Ukrainian looping a forehand long.
Tribute to Dad
The Dane, who says that a major reason for retiring was to start a family with her husband and former NBA star David Lee, admitted that she feared at the beginning that Yastremska would blow her away.
"She came out swinging... and everything was going in, even balls that I don't think she knew were possible to hit it that way," said Wozniacki, who has won 30 WTA titles in a professional tennis career going back to 2005.
"I was just thinking to myself: it surely can't continue. If it's going to continue, then there is not much I can do."
Wozniacki, who began playing tennis aged seven, is coached by her father Piotr, a former professional footballer.
Asked what the best decision had been in her career, she said: "I think sticking with my dad and that partnership, I think, has made me the player that I am today.
"I definitely wouldn't have been where I am today if it wasn't for him because the trust that was there between us and just the journey was amazing."
Results on day three of the Australian Open Grand Slam at Melbourne Park on Wednesday:
Sam Querrey (USA) bt Ricardas Berankis (LTU) 7-6 (7/2), 4-6, 6-4, 6-4
Stefanos Tsitsipas (GRE x6) bt Philipp Kohlschreiber (GER) retired
Guido Pella (ARG x22) bt Gregoire Barrere (FRA) 6-1, 6-4, 3-6, 6-3
Sara Sorribes (ESP) bt Veronika Kudermetova (RUS) 2-6, 6-1, 6-1
Anett Kontaveit (EST x28) bt Astra Sharma (AUS) 6-0, 6-2
Iga Swiatek (POL) bt Timea Babos (HUN) 6-3, 6-2
Carla Suarez (ESP) bt Aryna Sabalenka (BLR x11) 7-6 (8/6), 7-6 (8/6)
Heather Watson (GBR) bt Kristyna Pliskova (CZE) 4-6, 6-3, 6-1
Anastasia Pavlyuchenkova (RUS x30) bt Nina Stojanovic (SRB) 6-1, 7-5
Taylor Townsend (USA) bt Jessica Pegula (USA) 6-4, 7-6 (7/5)
Elise Mertens (BEL x16) bt Danka Kovinic (MNE) 6-2, 6-0
Ashleigh Barty (AUS x1) bt Polona Hercog (SLO) 6-1, 6-4
Elena Rybakina (KAZ x29) bt Greet Minnen (BEL) 6-3, 6-4
Alison Riske (USA x18) bt Lin Zhu (CHN) 6-3, 6-1
Julia Goerges (GER) bt Petra Martic (CRO x13) 4-6, 6-3, 7-5
Ekaterina Alexandrova (RUS x25) bt Barbora Krejcikova (CZE) 6-1, 6-3
Petra Kvitova (CZE x7) bt Paula Badosa (ESP) 7-5, 7-5
Naomi Osaka (JPN x3) bt Zheng Saisai (CHN) 6-2, 6-4
Zhang Shuai (CHN) bt Caty McNally (USA) 6-2, 6-4
Sofia Kenin (USA x14) bt Ann Li (USA) 6-1, 6-3
Ons Jabeur (TUN) bt Caroline Garcia (FRA) 1-6, 6-2, 6-3
Caroline Wozniacki (DEN) bt Dayana Yastremska (UKR x23) 7-5, 7-5