While it was a triumphant night for Australia, the mighty US team were shut out of the gold -- coming up with three silvers from the four finals.
Horton clocked 3min 41.55sec to hold off a feverish challenge from 2012 gold medallist Sun, who briefly looked to have the Australian beaten on the last lap but had to settle for second in 3:41.68.
Italy's Gabriele Detti roared home in the final 50 meters to capture bronze in 3:43.49.
Horton, whose mild manner and Harry Potter-style spectacles belie his toughness, said he knew that by calling Sun out he'd put himself on the spot.
More From This Section
"Well that last 50 I was kinda thinking about what I said and was like, if he gets me here it's not going to look great," Horton said.
"So (I) really didn't have a choice but to beat him."
Horton's terse comment that he couldn't respect a drug cheat reverberated at an Olympics that started under the cloud of the Russian doping crisis.
"I don't think I need to explain myself any further," he said. "I'm clean and have done what it takes to prove I'm clean... All athletes should be shown respect."
Horton's victory ensured Australia wouldn't suffer their ignominious London fate of failing to earn a single individual gold in the pool.
But things did get better for Australia as Emma McKeon, Brittany Elmslie, Bronte Campbell and individual world record-holder Cate Campbell won the relay in 3:30.65, lowering the world record of 3:30.98 set by an Aussie squad at the Commonwealth Games in 2014.
Hungary's "Iron Lady" Katinka Hosszu captured the Olympic gold that has long eluded her with a scintillating world record of 4:26.36 in the women's 400m individual medley.
She sliced 2.07sec off the previous record of 4:28.43 set by China's Ye Shiwen in winning gold in London.
At the 300m mark, Hosszu was move than five seconds under world-record pace.
Far behind her, the battle for second unfolded with American Maya DiRado taking silver in 4:31.15 and Spain's Mireia Belmonte third in 4:32.39.
Hagino's time made him the third-fastest performer in history behind world record-holder Michael Phelps and 2012 Olympic champion Ryan Lochte.
Neither of those US stars were in action on Saturday, Phelps opting out of the gruelling event he dubbed "swimming's decathlon" and Lochte failing to qualify at the US trials.
Hagino seized the lead from compatriot Daiya Seto on the second, backstroke, leg and never relinquished it. Kalisz pushed past Seto on the breaststroke but didn't have quite enough to get past Hagino on the closing freestyle, taking silver in 4:07.75 to Seto's 4:09.71.