Williams was two points from victory but could not finish the job and bowed out with a 7-5, 1-6, 7-6 (10-7) defeat on Tuesday night.
They played at Centre Court with the arena’s retractable roof closed after the first set.
Williams is a 23-time Grand Slam champion but the 40-year-old American had not competed in singles since she got injured in the first set of her first-round match at the All England Club on June 29, 2021.
She has won Wimbledon seven times. This was only the third first-round exit in 80 career Grand Slam appearances for Williams. One came at the French Open in 2012 and one at Wimbledon a year ago when she had to stop playing because of an injured leg.
This was Tan’s Wimbledon debut.