It is the first time the city, which is known as Russia's sports city, will host the event and caps a remarkable run for the country having also been awarded the 2014 Winter Olympics and 2018 soccer World Cup.
Mexico's Guadalajara was also awarded the 2017 championships by world governing body FINA on Friday. Hong Kong was the unsuccessful bid city.
The Russian delegation, whose late entry to the main press venue at the centre on Shanghai's Huangpu River had delayed the announcement by FINA president Julio Maglione, celebrated wildly, letting off party poppers and swigging from champagne bottles after Maglione opened the envelope.
The much smaller Mexican delegation was more reserved, accepting the applause from the gathered FINA dignitaries and the Russian delegation.
"It is a great step forward for the Russian federation," Maria Kisseleva, a triple Olympic champion in synchronized swimming who spoke at the final bid presentation on Friday, told Reuters through an interpreter.
"Kazan also has the 2013 Universiade and there is now the FINA and the World Cup and the (Winter) Olympic Games.
"It was especially important for me because my whole life I dedicated to synchronised swimming," she added. "(And) the championships is something that is close to me."
Kisseleva said the city's vibrancy had helped the bid team and that its youthful demographic would ensure a full house.
"For the last few years I have been working in Kazan and it is fantastic and amazing the way the city is growing.
"The (sports) venues are growing like mushrooms in the rain and people living in Kazan are sports mad."
The 14th world swimming championships open in Shanghai on Saturday with the 15th edition to be held in Barcelona in 2013.
Kazan an ancient city near the Volga River some 800 km (500 miles) east of Moscow, has also been selected to stage September's tennis Davis Cup World Group playoff against Brazil.
Russia's tennis chief Shamil Tarpishchev said the contest will be staged at a newly-built indoor tennis arena.
"We'll put up a fast court that should give us an advantage against the Brazilians who are more used to playing on clay," Tarpishchev was quoted as saying by local media.
"It is the first time Kazan will host an international tennis match so I have no doubt we'll have a full arena every day and the fans would give us a great reception."