Staff_collecting_engraver, see Issue 2199. This solution (courtesy of Shevek, see the lilypond-user archive) defines a custom
MarkLinecontext which will display all metronome and rehearsal marks and may be inserted anywhere between staff and other lines.
Remark from LSR-editor: Issue 2199 is solved in 2.21. In this regard this snippet is deprecated, for now we let it in as an example how to define a custom context like