Know Allah in prosperity, He will know you in adversity – Imam Ibn Rajab al-Ḥanbalī
Selections  from Jāmi’ al-‘Ulūm wal-Ḥikam:
 Taken from Ibn Rajab al-Ḥanbalī’s book Jāmi’ al-‘Ulūm wal-Ḥikam, an explanation of the forty-two famous ḥadīth collected by Imām al-Nawawī. The ḥadīth explained in this article is number nineteen.
The prophet ( صلّى الله عليه وسلّم ) said:
“Know Allah in prosperity, He will know you in adversity.” 
When a worshipper is conscious and fearful of Allah in times of ease and wellbeing, preserving His rules and paying careful attention to His rights upon him, he begins to know Allah. There is then established between him and his Lord a special relationship. In return, his Lord will remember and know His worshipper during his times of hardship. He will preserve and take care of such person’s relationship with Him in difficult times. Because of this relationship, Allah saves his worshipper from his difficulties. This special relationship brings an individual close to his Lord and ensures His love for him and His answering of his prayers.
A person’s “knowing his Lord” is of two types:
1. A general knowledge. When a person is familiar with Allah is this manner, he simply accepts that He exists, affirms correct belief in Him, and has faith in Him. All believers in general know Allah in this way.
2. A specific knowledge and relationship. When a person truly knows Allah, he turns his heart completely to Him, devotes himself to Him, and feels at ease with Him. He is comforted when Allah is mentioned although he is still shy before Him and fears Him. Those who truly know Allah focus on this specific type of “knowing Him.”
Similarly, Allah’s “knowing his servant” is of two types.
1. A general knowledge. This is Allah’s knowledge of all His servants, His observation of everything they conceal or make apparent, as He ( تعالى ) says:
“And indeed We have created mankind, and We know what his own self whispers to him.” 
Another example of this general type of Allah knowing His creation is His statement:
“He was most knowing of you when He produced you from the earth and when you were fetuses in the wombs of your mothers.” 
2. A specific knowledge and relationship. This type of “knowing His servant” is when Allah loves His worshipper, brings him close to Him, answers his prayers, and helps him out of difficulties. This is the type of relationship the prophet ( صلّى الله عليه وسلّم ) refers to when he said that Allah says (in a ḥadīth qudsī):
“My servant continues to come close to Me with extra acts of worship until I love him. When I love him, I become his ears with which he hears, his eyes with which he sees, his hand with which he strikes, and his leg with which he walks. Were he to ask Me for anything, I would certainly give it him, and were he to seek My help, I would certainly help him.” 
Illustrating this specific type of Allah knowing His servants, there is a report that when al-Ḥasan was fleeing the oppression of al-Ḥajjāj, he came to the house of Ḥabīb Ibn Muḥammad. Ḥabīb said to him, “Abū Saī’d, is there no relationship between you and your Lord by which you could pray to Him to hide you from these people? Come into the house.” al-Ḥasan went inside, and al-Ḥajjāj’s soldiers went in after him but could not see him. When that was mentioned to al-Ḥajjāj, he said, “He was inside the house but Allah blinded your eyes so that you could not see him.”
In summary, whoever shows Allah constant, respectful fear and obedience during times of ease and prosperity, Allah will show him gentleness and assistance during times of difficulty and adversity.
al-Tirmidhī recorded a ḥadīth from Abū Hurayrah ( رضي الله عنه ) that the prophet ( صلّى الله عليه وسلّم ) said:
“Whoever would like Allah to answer him during hardships and difficulties then let him increase in supplication during times of wellbeing.” 
The most difficult hardship a servant faces in this life is death; what comes after it is even more severe if the servant’s final destination is not good (Paradise). So it is necessary for a believer to prepare for death and what follows it during times of ease and wellbeing by remaining constantly conscious and fearful of Allah and doing righteous deeds (during life). Allah ( عزّ وجلّ ) says:
“Oh you who believe, fear Allah and let every soul look to what it has put forth for tomorrow. And fear Allah, indeed Allah is aware of what you do. And do not be like those who forgot Allah so He made them forget about their own souls. Those are the defiantly disobedient ones.” 
Whoever remembers Allah while in good health, in times of ease and comfort, and prepares himself for his meeting with Allah ( عزّ وجلّ ) upon death and afterwards, Allah will in return remember him during these hardships (associated with death). He will be with the person during such difficulties. Allah will be gentle with him as He assists him, takes care of him, and keeps him firm upon the worship of Allah alone (when he dies). Allah will then meet the person while being happy with him.
On the other hand, whoever forgets Allah during times of ease and comfort (in life) and fails to prepare for his meeting with Him, Allah will forget him during these hardships (of death). And the “forgetting” here means Allah will abandon the person and disregard him.
But when death comes to a true believer in Allah, one who has prepared for it and has good expectations of his Lord, and the good news of Allah comes to him, he then would love to meet Allah and Allah would love to meet him. However, a wicked person is just the opposite of that (i.e., he hates to meet Allah so Allah hates to meet him). The believer is then filled with happiness with what he put forth before him (in life) and with what he is about to arrive at (Paradise). As for someone who is negligent (who forgot about his own soul), he is filled with regret, saying:
“Oh, how I regret what I neglected regarding Allah.“ 
 This is part of a longer ḥadīth recorded by Aḥmad, al-Bayhaqī, and al-Lālakāī and Shaykh Nāṣir al-Dīn al-Albānī said it is authentic in his al-Jāmi’ al-Saghīr wa Ziyādatuh (5272).
 The Quran, Sūrah Qāf (50:16)
 Sūrah al-Najm (53:32)
 Recorded by al-Bukhārī
 Recorded by al-Tirmidhī (no. 3382) and al-Albānī said it is ḥasan in Ṣaḥīḥ Sunan al-Tirmidhī (no. 2693).
 Sūrah al-Ḥashr (59:18-19)
 About this type of “forgetting” them, Allah says in Sūrah al-‘Arāf (7:51):
So today We will forget them just as they forgot the meeting of this day of theirs and for having rejected Our verses.
And His ( سبحانسَه وتعالى ) frightening verses in Sūrah ṬāHā (20:124-126):
And whoever turns away from My remembrance, he will certainly have a depressed life, and We will gather him on the Day of Resurrection blind. He will say, “My Lord, why have you raised me blind while I used to see?” (Allah) will answer, “Likewise Our signs came to you but you forgot them, so likewise you will today be forgotten.”
 About this, the messenger of Allah ( صلّى الله عليه وسلّم ) said (recorded by al-Bukhārī):
Allah says, “If my servant loves to meet Me, I love to meet him, and if he hates to meet me, I hate to meet him.”
 Sūrah al-Zumar (39:56)
[Note: Arabic Text of the Verses and Hadeeth not mentioned in the above article. Please read the below PDF for the same]
Courtesy of authentic-translations.com
Translated by Abu az-Zubayr Harrison hafidhahullaah