Fiqh-us-Sunnah Volume 004, Funerals and Dhikr, Fiqh 4.037.

Section : Funeral Prayer, its Legal Status.

There is a consensus among all the great Muslim jurists that a funeral prayer for a deceased person is a collective obligation or fard kifayah. The Prophet, peace be upon him, commanded the Muslims to offer it, and they have been doing so ever since they received this commandment.

Abu Hurairah reported that when the Prophet, peace be upon him, was informed of the death of a person, he used to ask: Does he owe anything to anyone?' If the answer was in the affirmative, he would then ask: 'Has he (the deceased) left anything to settle his debt?' If he had left something to settle his debt, he would offer the funeral prayer for him. Otherwise, he would say to the Muslims: 'Offer a (funeral) prayer for your brother"' (Bukhari and Muslim).