Ko held off a late charge from Germany's Esther Henseleit, who claimed silver two strokes behind, with China's Lin Xiyu a further shot back to take bronze.
The 27-year-old New Zealander, a two-time major winner and former world number one who first topped the rankings aged 17, was chasing gold to add to her silver in Rio and bronze in Tokyo.
South Korean-born Ko started the final round as co-leader with Morgane Metraux of Switzerland and was cruising towards victory as she advanced to 11 under after her front nine holes to establish a five-stroke lead over Henseleit.
But a wayward shot on the 13th found the water en route to a double bogey, opening the door for Henseleit, who cut Ko's lead to one stroke.
Playing in the final group, Ko kept her nerve with a string of par putts before slotting in a birdie on the 18th green to bag gold on 10 under par.
"I just stayed patient and stuck to my game plan, and you know, 18, that tee shot and the second shot was probably two of the most important shots in my life," she told reporters after the medal ceremony in which she shed tears on the podium.
Paris will be her final Games, she said after the victory which secures her entry into women's golf LPGA Hall of Fame.
Henseleit's superb fourth-round performance, the second-best score of the day, yielded a first Olympic women's golf medal for Germany and Europe.
For China, Lin Xiyu, who also calls herself Janet Lin, is the country's second women's golf medallist after Feng Shanshan, who won bronze in Rio.
Metraux slumped to tied 18th at two under par, failing to recover from two bogeys and a triple bogey in her first five holes. The Swiss Olympic debutant said dizziness during the round contributed to a tough day.
Finishing on the same score as Metraux was France's Celine Boutier, who had thrilled home fans by taking thefirst-round lead.
Defending champion and world number one Nelly Korda of the United States fell out of medal contention during the final round to end at one under par in tied 22nd.