This is the story of a Jinn which was alive from the time of Adam (عليه السلام) till the time of the Prophet (صلى الله عليه وسلم), and even met the Prophet (صلى الله عليه وسلم) conveying a very special message.
Reference of the story is narrated in the book of Ibn Hajar al Asqalani (رحمه الله) called Al Isabah fi Tameezis Sahabah vol 6, p518 (Beirut print)