Heather Watson will play Venus Williams in the second round of the Silicon Valley Classic after struggling to a 6-4 3-6 6-4 win over wild card Claire Liu.
World No 133 Watson took the first set in 47 minutes after breaking for a 4-3 and then a 5-4 lead.
But American Liu, ranked 21 places below Watson, recovered to take the second set, which saw four consecutive breaks of serve.
Watson recovered to claim the deciding set in 52 minutes, breaking early before racing to a 3-0 lead, but was broken back as Liu drew level at 3-3.
An epic seventh game saw Liu miss three break points, before the final game saw Watson win on the first of two break, and match, points, to advance to round two and a meeting with five-time Wimbledon winner Williams.