The 38-year-old, who rides for Movistar, finished the 258km route in a time of 6:46:41.
Second place went to France’s Romain Bardet, while Canada’s Michael Woods rounded out the podium.
Netherlands’ Tom Dumoulin finished in fourth position, with Italy’s Gianni Moscon in fifth.
It was a long-fought battle for the Spaniard who had competed in the world champs 18 times, winning the silver medal twice and the bronze four times.
“It’s incredible. Fighting, fighting, it’s a dream,” said Valverde.
“I have to thank the team because they were a ten [out of ten]. I was saving it for the sprint and the truth is it’s just something incredible. This has been a dream of mine to be a world champion.”
View more results below.
1. Alejandro Valverde (Spain) 6:46:41
2. Romain Bardet (France)
3. Michael Woods (Canada)
4. Tom Dumoulin (Netherlands)
5. Gianni Moscon (Italy) +0:00:13
6. Roman Kreuziger (Czech Republic) +0:00:43
7. Michael Valgren Andersen (Denmark)
8. Julian Alaphilippe (France)
9. Thibaut Pinot (France)
10. Rui Costa (Portugal)
11. Jon Izaguirre Insausti (Spain)
12. Bauke Mollema (Netherlands) +0:00:49
13. Mikel Nieve Iturralde (Spain) +0:00:52
14. Sam Oomen (Netherlands) +0:01:21
15. Nairo Quintana (Colombia)
16. Peter Kennaugh (Great Britain)
17. Jan Hirt (Czech Republic)
18. George Bennett (New Zealand)
19. Jack Haig (Australia)
20. Jakob Fuglsang (Denmark)
DNF Jacques Janse van Rensburg (South Africa)
DNF Nicholas Dlamini (South Africa)