Balandin, swimming in lane eight after qualifying as the slowest finallist, touched the wall in two minutes, 7.46 seconds, just 0.07 seconds ahead of Josh Prenot of the United States.
Russia's Anton Chupkov took the bronze in lane seven, with 0.24 seconds separating the top three.
In swimming finals, the fastest qualifiers take the central lanes four and five, and a win in the outside lane is a rarity.
'Devastated' Peaty to miss World Championships after training accident
11/05/2022 AT 13:59
"There are pluses and minuses. On the one hand you don't see your opponents and so it's very hard," Balandin said.
"On the other hand the plus is that if you don't see them you can concentrate just on the result instead of whether to shadow someone."
The Russian-speaking Kazakh said he and Chupkov had joked about their lanes before the race.
"Anton and I agreed: I told him I'll look at you and you look at the ones further along, and that's how we'll get our bearings."
On a video feed, the two could be seen chatting in the call room before the race.
"While everyone else was concentrating very hard and getting nervous, we were relaxed and talking like friends," the 21-year-old said.
"To be honest, we were saying we just needed to get through the next two minutes and it would all be over."
Balandin's mother watched in tears as he paraded with his gold medal around the poolside.
Japan's Yasuhiro Koseki had seized control of the race from the outset, leading until the 150-metre mark and well under world record pace before he tied up over the final lap.
Kazakhstan, who lost five Olympic titles from 2008 and 2012 through retrospective doping positives, had earlier won their first gold of the 2016 Games when Nijat Rahimov broke the clean and jerk world record in the men's 77kg weightlifting.
Balandin learned of Rahimov's gold only after winning his own, saying he had been "a bit cut off from the world" for the previous hour.
"It's probably the biggest honour and the best thing I could do for my country," he said.
"I'm very proud of this. This is history, the first swimming medal for Kazakhstan, and I'm very glad I wrote it."
GB's Andrew Willis finished an agonising fourth.
"I was dreading turning around to see the result," Willis told the BBC after the race.
"I knew I was up there but the action was happening on the outside of the pool. I gave it everything on that last length. I'm not sure I left it too late, I tried to control it."


1. Dmitriy Balandin (Kazakhstan) 2:07.46
2. Joshua Prenot (U.S.) 2:07.53
3. Anton Chupkov (Russia) 2:07.70
4. Andrew Willis (Britain) 2:07.78
5. Yasuhiro Koseki (Japan) 2:07.80
6. Ippei Watanabe (Japan) 2:07.87
7. Marco Koch (Germany) 2:08.00
8. Kevin Cordes (U.S.) 2:08.34
Eight Olympic champions in British squad for FINA World Aquatics Championships
14/04/2022 AT 20:08
Eight Olympic champions named in British squad for FINA World Aquatics Championships
14/04/2022 AT 18:31