c. 1200, dirige (the contracted form is from c. 1400), "that part of the Office for the Dead beginning with the antiphon for the first psalm of the first nocturn of matins," from Latin dirige "direct!" imperative of dirigere "to direct" (see direct (v.)). The antiphon begins, Dirige, Domine, Deus meus, in conspectu tuo viam meam ("Direct, O Lord, my God, my way in thy sight"), from Psalms v.9.
Hence, broadly, "the funeral service as sung." Transferred sense of "any funeral song or hymn, a song or tune expressing grief" is from c. 1500.