It is narrated from Sayyiduna Anas (may Allah be pleased with him) that the Prophet (peace and blessings be upon him) said: "Whoever goes out to seek knowledge is in the path of Allah, the Blessed and Exalted, until he returns."
Imam al-Tirmidhi (may Allah have mercy on him), after narrating it through Nasr bin Ali, said: "This hadith is hasan gharib." He also said: "Some narrators narrated it but did not report it as marfu' (attributed to the Prophet (peace and blessings be upon him))."