It is narrated from Sayyiduna al-Hasan bin Ali (may Allah be pleased with them both) that he said: I heard the Messenger of Allah (peace and blessings be upon him) say, or (he said that) the Messenger of Allah (peace and blessings be upon him) said: "When a funeral is present and the ruler of the time is also present (there), then the ruler has the greater right to lead the funeral prayer over it."
Imam Ahmad bin Mani' recorded it with a chain that includes a narrator named al-Hasan bin Umarah, and he is da'if (weak).