The En Yaakob in Masechet Sota (14) presents an interesting Girsa (version) of the Talmudic text that provides an authoritative source for the common custom to pray at the graves of Sadikim. According to this Girsa, the Gemara raises the question of why G-d saw to it that nobody would know the site of Moshe’s burial ("Ve’lo Yada Ish Et Keburato" – Debarim 34:6). The Gemara answered that G-d, who of course foresees all future events, knew that He would have to destroy the Bet Ha’mikdash and exile Beneh Yisrael from their land. If they knew the location of Moshe’s burial site, they would go there and pray, urging Moshe to beseech the Almighty on their behalf. The Sages teach that "the righteous are more beloved in death than during their lifetimes," and thus Moshe’s prayer would have succeeded in annulling the decree of destruction and exile. G-d, who, for reasons known only to Him, wanted to destroy the Mikdash and send the Jews into exile, therefore concealed the whereabouts of Moshe’s grave, so that the decree of exile would not be annulled.
This account demonstrates the unique power and significance of prayer at the gravesites of the righteous, through which the soul of the Sadik comes before G-d to advocate on our behalf.
Another basis is the Torah’s account of the spies who were sent to Eretz Yisrael. The Torah (Bamidbar 13:22) tells that when the spies reached the Land of Israel, "Va’yabo Ad Hebron" – "He came to Hebron." As Rashi cites from the Midrash, the Torah speaks here in the singular form because it was specifically Kaleb Ben Yefuneh who went to Hebron in order to visit the gravesites of the patriarchs and matriarchs in the Machpela Cave, where he prayed that he be saved from the evil plot of the other spies. Indeed, Kaleb opposed the other spies who spoke negatively about the land, and this was in the merit of the Sadikim by whose graves he had prayed. This account, too, demonstrates that there was an ancient custom to visit the graves of Sadikim, and that these prayers are immensely valuable.
Likewise, the Arizal (Rav Yishak Luria of Safed, 1534-1572) taught that the primary residence of the Shechina nowadays is at Keber Rahel, the gravesite of our matriarch, Rahel, and thus for centuries Jews have been going to the site to pray, both for the Shechina, that it should come out of exile, and for their own personal needs.
The Ner Le’siyon (p. 96; listen to audio recording for precise citation) discusses this time-honored custom, and explains that the purpose of visiting the graves of Sadikim is to ask that their souls pray on one’s behalf, as in the case of Kaleb. The Ner Le’siyon also cites the Gemara’s comment in Masechet Ta’anit (16) that during periods of severe drought, people would go to the cemetery to pray. Furthermore, the Zohar (Shemot, p. 16b; listen to audio recording for precise citation) writes that if the souls of the deceased would not pray on behalf of the living, the living would not survive for even half a day. And the Sefer Hasidim (450) comments that the soul of a deceased person experiences great pleasure when his or her loved ones come to pray at the gravesite. These prayers provide immense benefit for the soul in the next world, thus prompting them to pray to G-d on behalf of the living.
All these sources demonstrate the value and significance of praying at the graves of Sadikim, and the benefit this provides to both the deceased and the living.