A netted forehand down the line from Townsend ended the set at 6-3 after 29 minutes of play.
Williams took the first three games of set two before Townsend held serve to reach 3-1.
Serving at 1-4, 40-30, Townsend approached the net only to see a Williams running crosscourt forehand pass her for a winner to reach deuce.
Townsend committed two forehand down the line errors to drop serve to trail 1-5.
With Williams serving for the match, several forceful serves from Williams resulted in three Townsend backhand errors coupled with a crosscourt forehand hit long to end the match.
Williams finished the night with 16 winners to 8 unforced errors while Townsend finished with 8 winners to 20 unforced errors.
Williams, who did not face a breakpoint in the match, won the US Open in 1999, 2002, 2008, 2012 and 2013.
Townsend, playing in her debut US Open, had previously became the first American to hold the year-end top world junior girls ranking since Gretchen Rush in 1982.