Japan's Osaka is a two-time champion at Flushing Meadows, winning the first of her four Grand Slam titles in New York in 2018 and repeating the feat in 2020.
She missed last year's tournament after giving birth to daughter Shai but watched from the crowd, which reignited her desire to compete.
The former world number one faced a tough task against Latvian 10th seed Ostapenko, but came through 6-3 6-2 in just 63 minutes.
Osaka covered her face with her towel as she cried tears of joy and relief after the win, and became emotional again in her on-court interview.
"I was trying not to cry when I was walking out," the 26-year-old said.
"I remember last year I was watching Coco [Gauff] play and I so badly wanted to step on these courts again.
"I didn't know if I could - athletically, physically, if I was able to. Just to play this match and be in this atmosphere means so much to me, so thank you."
Victory over Ostapenko was Osaka's first against a top-10 player for four years.
Osaka, who also won the Australian Open in 2019 and 2021, spoke before the US Open about not feeling "like I'm in my body" since her return from maternity leave.
She gave birth to daughter Shai in July 2023 and returned to the WTA Tour in January.
Although she has had some notable performances - including coming within touching distance of beating eventual champion Iga Swiatek at the French Open - she has not gone beyond the quarter-finals of any event.
She also has a tough draw in New York, with former French Open finalist Karolina Muchova awaiting in the second round.
Asked about her goals for the tournament, Osaka said: "Keep focusing, keep trying to play really well, but overall have a lot of fun.
"Last night my daughter didn't want to go to sleep on her bed time, so I had to hold her for quite a while and I was thinking: Oh wow, she really picked the perfect day not to go to sleep.
"Moments like that are so precious to me and I can only hope I keep having more."
bbc