Dean touched home in one minute 44.22 seconds, securing a British record on his debut Games.
Scott finished just 0.04secs behind his team-mate, with Fernando Scheffer of Brazil taking bronze.
It is the first time since 1908 that two male British swimmers have finished on the Olympic podium together.
The 21-year-old Dean had a difficult build-up to Tokyo after twice contracting coronavirus in 2020, which at one stage left him unable to “walk up the stairs without coughing and wheezing”.
Unable to train for three weeks on each occasion, his return to the pool had to be adapted to prevent any long-term damage to his body.
Despite the disruption, he arrived at the Games as the second-fastest man in the year, behind Scott.
“When I was sitting in my flat in isolation, an Olympic gold seemed a million miles off,” Dean said.
“It is a real honour. I watched the flag go up and the anthems be played, it is the stuff of dreams.
“Thanks so much to everyone back home – my mum, my family, my girlfriend. All the boys back in Maidenhead – thank you for staying up.”
The two Britons high-fived before sharing a hug as their remarkable podium finishes were confirmed.
Both swimmers looked shocked as they spoke to BBC Sport afterwards, with Scott describing it as an “unbelievable moment”.
Scott, who qualified fastest, was the favourite going into the race but Dean was able to back up his rapid start with a strong finish.
Scott, who won European silver in May, said he was “just buzzing for Deano” as the two good friends allowed their victory to sink in.
The British team – including Adam Peaty, who won a historic 100m breaststroke gold on Monday – cheered the two on from the stands, with several reduced to tears by the emotion of the moment.
“You can’t describe that. When you have worked so hard, to share this medal moment with one of your best friends is an unbelievable feeling,” two-time Olympic gold medallist Rebecca Adlington told BBC TV.
“Duncan will be slightly disappointed because he was the fastest and the favourite but, at the end of the day, you can tell that if anyone were to beat him, he would want it to be his team-mate.” (Courtesy BBC)