The core obligation of levaya is established in Berakhot 18a:12 and codified in Shulchan Arukh, Yoreh De'ah 361:1-4, which rule that one who sees a corpse and fails to escort it at least four cubits transgresses the prohibition of 'mocking the poor,' and that even where one is not obligated to accompany the dead, one must still rise before it. Arukh HaShulchan, Yoreh De'ah 361:1-8 elaborates on this as a great mitzvah whose fruit is eaten in this world while the principal remains for the next, citing the same Gemara and the Yerushalmi that one stands not for the corpse itself but in honor of those performing the chesed.
Accompanying the dead is given extraordinary priority, even over Torah study: Ketubot 17a:11-12 and Megillah 3b:7-9 state that one suspends Torah study to attend a funeral procession when there are not enough people present to adequately honor the deceased, and Mishneh Torah, Mourning 14:2 calls the reward for levaya greater than any other mitzvah, tracing it to the practice of Avraham Avinu and teaching that one who fails to escort is as if he shed blood. Mishneh Torah, Mourning 14:7-8 further rules that between a corpse and a bridal procession, tending the corpse takes precedence, and both yield before a king.
Sukkah 49b:8 roots the levaya specifically in the verse 'to walk humbly with your God,' identifying the taking out of the poor dead for burial as an act that must be done without fanfare, and reasons a fortiori that if the Torah demands discretion even for public acts like funerals, how much more so for acts naturally done privately. Shulchan Arukh, Yoreh De'ah 358:1 distinguishes among those accompanying: the pallbearers before and behind the bier, who are needed for carrying, are exempt from Shema and prayer, while other accompaniers not needed by the bier remain obligated.
Practical details of the procession itself are addressed by Shulchan Arukh, Yoreh De'ah 358:3 and Arukh HaShulchan, Yoreh De'ah 358:5, which describe customs where mourners and relatives exit the house first, take up the bier on their shoulders, and where the bier is set down several times en route to the grave before tzidduk hadin is recited. Sifrei Devarim 221:6 separately teaches that delaying burial transgresses a prohibition unless the delay is for the deceased's honor, such as procuring a coffin and shrouds, which is not considered disgraceful delay.
Standing in respect for a passing bier even by those exempt from joining it is reinforced by Moed Katan 27b-28a, which records that all must rise before a Nasi except a mourner or the ill, paralleling the deference owed to a funeral procession noted above. The narratives of Bereishit 50:1-14 and Bereishit 23:2-19 depict large-scale accompaniment of the dead—Yosef bringing Pharaoh's officials and dignitaries to bury Yaakov, and Avraham rising from before Sarah to secure her burial—while Shmuel II 1:11-12 shows David and his men mourning and fasting for Shaul and Yonatan, and Sotah 14a:4 teaches that burying the dead is itself an emulation of Hashem's own act of burying Moshe.
Several halachic details specific to levaya on Yom Tov and regarding a kohen's participation are addressed: Shulchan Arukh, Orach Chayim 526:6-7 permits accompanying a corpse on the first day of Yom Tov within the techum and on the second day even beyond it, while forbidding those accompanying from riding an animal even on the second day unless burial is otherwise impossible. Melammed Lehoil Part II 133:1-2 and Responsa Rav Pealim, Volume III, Yoreh Deah 23:1 take up whether a kohen may walk behind the bier or ride in an enclosed vehicle through a tree-covered passage or into a cemetery, debating whether such a conveyance halachically interposes against tumah.
Gesher HaChaim 5:1-6 establishes that one may not eat, drink, learn Torah, recite blessings, or display tzitzit and tefillin within four cubits of the corpse or in its presence anywhere in the same house, though reciting Tehillim or delivering a eulogy in the deceased's honor is permitted, and Gesher HaChaim 14:1-9 discusses when the duty to accompany yields to an existing chevra kadisha and affirms that bystanders must still rise for a passing funeral procession even when exempt from joining it.
Gesher HaChaim 18 addresses those actually walking in the levaya procession, ruling that once the deceased has been handed over to the chevra kadisha for care, the mourners accompanying may recite Shema and pray during the procession itself, discreetly, if waiting until after burial would cause the proper time to pass. Gesher HaChaim 16 adds that women are generally careful not to join the levaya, and that even when they do, the custom is not to offer comfort to mourners there.
Revavos Ephraim 8:308 rules that one who accompanies the deceased should wash his hands afterward even if he did not come within four amot of the body, following the position of the Chazon Ish, though the reasoning behind this stringency is left unexplained.
Teshuvos V'hanhagos 1:681 addresses the timing of kriyah for those who do not accompany the meis all the way to the cemetery, ruling that the proper moment is after the hesped and before burial, when the mourners' grief is at its height, and that such people should tear their garments at that point in the presence of the assembled congregation before it disperses.