George Bush, the US president, and his father, the former US president, joined spectators to watch Phelps compete.
“I’m pretty happy with that, it was a pretty emotional race,” said Phelps, who described Bush’s presence as “cool.”
Hungarian Laszlo Cseh took the silver medal with Ryan Lochte of the United States getting bronze.
Phelps, who won six golds in Athens in 2004, has his eyes on an unprecedented eight gold medals in Beijing, and had earlier described the 400m individual medley as his weakest race.
US swimmer Mark Spitz’s holds the current record of seven gold medals taken at one games, the 1972 Munich Olympics.
Even if he only wins half of his events, Phelps will still hold more golds than any other Olympic athlete in history.
Later on Sunday basketball fans were preparing for a blockbuster showdown between host nation China, led by NBA star Yao Ming, and a star-studded US team.
The Americans are hoping for a better performance than in Athens four year ago when the team scored a meager bronze.
Commentators say the evening match, which the US president is also expected to attend, could be the most-watched sporting contest ever in China.