Williams went down 7-5 1-6 7-6 (10-7) on Centre Court in her first singles match since being forced to withdraw in the opening round of last year's tournament at the All England Club, when she suffered a hamstring injury during a contest with Aliaksandra Sasnovich.
The seven-time Wimbledon champion's much-heralded comeback proved to be an almighty battle and it was the SW19 debutant from France who came out on top late on Tuesday evening.
It took outsider Tan three hours and 11 minutes to claim a huge scalp, winning what could prove to be the great Williams' final singles match at Wimbledon.
Tan broke three times in a back-and-forth first set, with Williams unable to keep her at bay during the seventh game despite the world number 115 seeing three break points come and go before winning the fourth.
The underdog's slice in particular proved to be difficult for the 40-year-old - 16 years senior to her opponent - to counter, and the former world number one seemed to need the break afforded by the roof closure on Centre Court to regather herself.
Williams stamped her authority on the match in the second set to force a decider, breaking twice as she surged into a 5-0 lead before serving it out.
Tan refused to be beaten in the final set, twice breaking back to frustrate Williams.
Williams was able to force a tie-break after saving a match point, and surged into a 4-0 lead - but Tan rallied once more to seize back the momentum, and celebrated a famous win after her legendary opponent netted a forehand.