The No. 14 seeds added the US Open title to the Australian Open they won in 2019.
Gauff and McNally were hoping to join 18-year-old singles champion Emma Raducanu as teenage titlists at the tournament. The No. 11-seeded Americans fell just short of adding the US Open doubles title to the juniors one they won together in 2018.
"I know that we'll be Grand Slam champions eventually,'' Gauff said.
But the veterans were a little too good, with Stosur adding this doubles title to the one she won in Flushing Meadows in 2005 and the US Open singles title she earned by beating Serena Williams in 2011.
"For us, this was our second Grand Slam final together. I've been in a few more,'' Stosur said. "It's kind of like, 'All right, I've done this a few more times than you, so I've got to try to use everything I've got.'''
Gauff and McNally rallied to tie the match, and it was even deep into the third set, before Stosur and Zhang broke McNally again for a 5-3 lead prior to Stosur serving out the match.
Stosur agreed that her opponents will have another chance.
"They just play fearless. Credit to them,'' she said. "I think they're a really great team. Again, no doubt they're going to be back in situations like this, challenging for titles."
"Not just yet,'' Stosur added with a smile. "Not today.''
Immediately after the final point, Gauff showed uncharacteristic frustration on the court, tossing her racket on the floor once, and then smashing it harder a second time. The racket appeared to land very close to a child who was watching courtside. She motioned an apology, handing the racket to him after that.
When asked about her reaction during the postmatch news conference, Gauff said, "I lost a Grand Slam final. I didn't mean for the racket to go as it did, but I did throw it. Probably not the best behavior on my side."
"I don't mean to do that in the moment, but I let my emotions take over," she added. "I don't regret it. I only regret the racket went so far and almost hit the kid."
Gauff said she spoke to the youngster after the match and that "he's fine."
"I was just frustrated for losing a Grand Slam final," she concluded.
ESPN's Aishwarya Kumar and The Associated Press contributed to this report.