Chen became the third female table tennis player to win gold medals in singles at two consecutive Olympics.
Sun, the world number one, won the opening game comfortably with an 11-4 score.
Chen remained calm under pressure, especially when she went behind in the sixth game, to win the match 4-2.
Two table tennis Grand Slam champions, Zhang Yining and Ding Ning, were present in the stands to watch the match.
In the earlier bronze-medal match, Japan's Hina Hayata overcame injury to defeat South Korea's Shin Yubin in a hard-fought 4-2 victory that left her in tears.
It was Japan's second medal in the event, following Mimo Ito's bronze in Tokyo three years ago.