Media playback is not supported on this device
World record holder Paul Biedermann of Germany was third with Ryan Lochte and Chad Le Clos outside the medals.
It is 19-year-old Guy's second medal of the meeting after winning silver behind Sun in the 400m freestyle on Sunday.
Fellow Briton Adam Peaty set a new world record of 26.42 seconds in the 50m breaststroke semi-finals.
Media playback is not supported on this device
Peaty, who won gold over 100m on Monday, beat the mark of 26.62 seconds set in the morning heats by South Africa's Cameron van der Burgh.
The pair will race again in the final on Wednesday afternoon.
In the same summer that Lochte collected five medals at London 2012, a 16-year-old Guy won a 400m freestyle bronze at the European Junior Championship - and the Bury teenager is struggling to comprehend his victory over the illustrious American.
"I never thought I'd race Ryan Lochte head to head like that - he is one of my heroes," said Guy.
"So to race him was amazing and to touch my hand on the wall first and be world champion hasn't sunk in quite yet. I am so happy.
"Coming in, I didn't think that I would make the final of the 200m, but I knew I had done some good sessions out in Majorca and back at home."
Liam Tancock finished eighth in the 100m backstroke final that was won by Australian Mitchell Larkin.
In the final race of the evening session, Russian Yuliya Efimova successfully defended her world title, edging out Plymouth-based Lithuanian Ruta Meilutyte in the 100m breaststroke despite trailing the Olympic champion by 0.49 seconds at the turn.
Efimova returned from a 16-month doping ban in March and Meilutyte has previously said that she no longer sees her rival as a "honest competitor".
Siobhan-Marie O'Connor, who won Britain's first world 200m individual medley medal with a bronze on Monday, fell short of making the 200m freestyle final. The 19-year-old set the 11th-fastest qualifying time in the heats and was 0.35 seconds slower than the final qualifier from the semi-finals.
Stephen Milne clocked seven minutes 46.41 seconds to qualify third-fastest for Wednesday's men's 800m freestyle final.
American Katie Ledecky lowered her own world record by 2.23 seconds as she swam clear of the field to successfully defend her 1,500m freestyle.
Great Britain's James Guy won world 200m freestyle gold in Russia, beating Olympic silver medallist Sun Yang of China by six hundredths of a second.