Her time of 2:08.65 meant she smashed her own British record for the heptathlon, finishing the seven-event competition with 6,955 points, 49 more than she scored in Gotzis in May.
Russia's world champion Tatyana Chernova took silver and Lyudmyla Yosypenko of Ukraine the bronze.
The 27-year-old swam the third butterfly leg to help the US past Japan before Nathan Adrian brought them home in the freestyle leg.
Australia took the bronze, with Great Britain in fourth.
Phelps ends his incredible career with 18 gold medals at Olympic Games and 22 medals in total.
image: © Marco PakÃ¶eningrat