Both players had lost their opening ties on Sunday so were desperate for a victory to keep their future fate in the eight-woman event in their own hands and neither appeared willing to budge in a titanic three hour and 13-minute marathon.
In the end, the 37-year-old Williams emerged from a bruising encounter that featured 20 breaks of serve with a victory built on her calmness at the key moments and ruthlessness when offered a chance to attack her opponent's weak second serve.
"Sometimes you need some luck. I don't know if I had any tonight as I had to work for every point," Williams said in a courtside interview.
'You'll never light a candle to me' - Venus Williams tells press how she deals with them
"It's not easy when you lose the first match. Both of us were in the same situation and you have to fight, what else can you do, to live another day."
The match started with Ostapenko trying to force the pace with the high-risk strategy that carried her to French Open glory, while Williams was content to pick up free points as her opponent sprayed a plethora of attempted winners wide or long.
Venus Williams au Masters féminin
Image credit: Getty Images
The Latvian edged ahead in the opener, however, and even served for the set at 5-3 but the veteran American dug deep and reeled off six consecutive games to first steal the set and then move ahead in the second.
The 20-year-old battled back as the pair traded two breaks apiece before Williams brought up a her first match point in the 10th game that she failed to convert when she dumped a forehand into the net as Ostapenko continued to go for her shots.
The pair's inability to hold serve spilled over into the tiebreak and Williams handed Ostapenko three set points with a wild forehand and the Latvian levelled the contest on the first of them when the American netted a backhand.
Four more breaks of serve followed in the decider until Ostapenko rallied from 0-40 to hold in the ninth game and the Latvian saved three more break points in the 11th before finally running out of lives when she sent a backhand wide.
Williams could smell blood and a booming ace brought up three more match points and the American sealed victory on the second of them with a crosscourt backhand winner.
Spanish world number two Garbine Muguruza takes on Czech third seed Karolina Pliskova in the second White Group match later on Tuesday. Both players won their opening matches on Sunday.
Highlights: Kostyuk ousts 2016 champ Muguruza
'A complete player' - Henin tips Osaka to dominate women's game