Be a Key to Good - Shaykh Ahsan Hanif

By Shaykh Ahsan Hanif | 2026-07-06T18:43:41.172418+00:00 | Topic: Hadith

Be a Key to Good

This companion, Sahl ibn Sa'ad رضي الله عنه وارضاه, during the life of the Prophet ﷺ was from the youngest companions — from the youngest companions of the Ansar of Medina. And he was the last of the companions to pass away in the city of Medina after the death of the Prophet ﷺ. A young companion, but still a prolific narrator of hadith.

The Hadith: Keys of Good and Evil

In this particular hadith, he narrates that the Prophet ﷺ said:

عِنْدَ اللَّهِ خَزَائِنُ الْخَيْرِ وَالشَّرِّ وَمَفَاتِيحُهَا الرِّجَالُ فَطُوبَى لِمَنْ جَعَلَهُ اللَّهُ مِفْتَاحًا لِلْخَيْرِ مِغْلَاقًا لِلشَّرِّ وَوَيْلٌ لِمَنْ جَعَلَهُ اللَّهُ مِغْلَاقًا لِلْخَيْرِ مِفْتَاحًا لِلشَّرِّ

(Sunan Ibn Mājah, Hadith 237)

The Prophet ﷺ said that all of the good and all of the evil — it is known to Allah. Allah has knowledge of everything. His knowledge encompasses everything. Allah knows all the good that is upon this earth and in the heavens, and all the evil that is upon this earth.

وَمَفَاتِيحُهَا الرِّجَالُ — But the good and the evil that we have in this world, its keys are people. Me and you. We are the keys that determine whether we do something good or we do something evil.

So the Prophet ﷺ said: طُوبَى — glad tidings and blessings — لِمَنْ جَعَلَهُ اللَّهُ مِفْتَاحًا لِلْخَيْرِ — to the one that Allah has made a key to goodness — مِغْلَاقًا لِلشَّرِّ — and a lock upon evil. وَوَيْلٌ — and woe betide, destruction and punishment — for the one لِمَنْ جَعَلَهُ اللَّهُ مِفْتَاحًا لِلشَّرِّ مِغْلَاقًا لِلْخَيْرِ — for the one that is a key to evil and a lock upon good.

This hadith, like many of the hadith of our Prophet ﷺ, is concise within its words and its statements. But it is comprehensive and full of meaning.

Good and Evil Are In Our Hands

The Prophet ﷺ in this hadith is pointing and drawing our attention to a number of key aspects — not least of which is this concept of good and evil. You see, we are very quick — especially in the time that we live in — to point the finger at others and to say that there is evil because of so-and-so. But often within our own communities, if every person took it upon themselves the onus and the responsibility to do what they can within themselves and for the people around them, we have control over what we can do in terms of good and evil. Allah has placed that ability within our hands.

When we see a situation transpire before us, when we deal with people, when we interact with others — whether you come into the masjid and there's something that takes place, or you're in the supermarket, or you're on the road, or you're at home with your family — you are the one who determines whether you will be a component of good or a component of evil. That is what our Prophet ﷺ is saying.

The reward in this religion is for the one who trains themselves to be a key of goodness — not only for themselves in terms of earning wealth and buying houses and cars and so on, but goodness in terms of benefiting others. That is the meaning of goodness in this hadith. Yes, you benefit yourselves and your families, but you are a means of good and benefit for those that are around you.

Who Are the Best Among Us?

In the hadith of Abu Hurairah رضي الله عنه, collected by al-Tirmidhi, the Prophet ﷺ said:

أَلَا أُخْبِرُكُمْ بِخَيْرِكُمْ مِنْ شَرِّكُمْ
خَيْرُكُمْ مَنْ يُرْجَى خَيْرُهُ وَيُؤْمَنُ شَرُّهُ وَشَرُّكُمْ مَنْ لَا يُرْجَى خَيْرُهُ وَلَا يُؤْمَنُ شَرُّهُ

(Jami' al-Tirmidhi, Hadith 2263)

He repeated this — "Shall I not inform you about the good amongst you and how different they are from the evil amongst you?" — three times to the companions. And then the Prophet ﷺ said: The best from amongst you are those who other people hope good from, and they know that they are safe from the evil. But the worst of you are those who others don't hope for any good from, nor do they feel safe from their evil.

That is the definition of goodness and evil within our religion.

Examples from the Qur'an and the Prophets

The Story of Musa (عليه السلام) in Madian

In the Qur'an, Allah gives us examples of goodness. The life of the Prophet ﷺ is full and replete with examples of goodness — of being a key for good and for change.

All of us live in a community and we live in a society. We have many issues that we deal with, whether on an individual, personal, family level, or as a community — whether it's the social challenges we face upon our streets with our shabab, our youth, drugs and alcohol and so on and so forth. All of us know people involved in one way or another, in problems and issues that are illegal or harmful. You have the opportunity to be a key of good or a lock for evil. Allah has given you that ability through advice, through sincerity, through wisdom, through gentleness, through mercy, through doing the right thing.

Allah gives us an example of this in the Qur'an, in the story of the Prophet of Allah, Musa عليه الصلاة والسلام. As Allah mentions in Surah Al-Qasas, Musa fled from Egypt. When he was grown, as Allah mentions in the Qur'an, he accidentally killed an Egyptian man and fled, fearing the oppression of Pharaoh. He fled to a place called Madian.

وَلَمَّا تَوَجَّهَ تِلْقَآءَ مَدْيَنَ قَالَ عَسَىٰ رَبِّىٓ أَن يَهْدِيَنِى سَوَآءَ ٱلسَّبِيلِ

This is before Musa عليه الصلاة والسلام becomes a Prophet of Allah, before Allah speaks to him on the mountain of At-Tur, before he is given the Torah, before he is given a message to carry back to Pharaoh.

Musa عليه السلام comes to Madian. He is a stranger, a foreigner in this land. He is fearing for his own life, running and escaping from oppression. But he comes into Madian and he sees a situation evolving in front of him.

وَلَمَّا وَرَدَ مَآءَ مَدْيَنَ وَجَدَ عَلَيْهِ أُمَّةًۭ مِّنَ ٱلنَّاسِ يَسْقُونَ وَوَجَدَ مِن دُونِهِمُ ٱمْرَأَتَيْنِ تَذُودَانِ ۖ قَالَ مَا خَطْبُكُمَا ۖ قَالَتَا لَا نَسْقِى حَتَّىٰ يُصْدِرَ ٱلرِّعَآءُ ۖ وَأَبُونَا شَيْخٌۭ كَبِيرٌۭ

He saw a group of men — shepherds, all of them — with their flocks going to a watering hole. وَوَجَدَ مِن دُونِهِمُ امْرَأَتَيْنِ تَذُودَانِ — but then on the side he saw two women also with a flock of sheep. But they were standing to the side, waiting for those men to finish.

قَالَ مَا خَطْبُكُمَا — So Musa عليه السلام has a choice. He is fearing oppression, doesn't want to be known, he's escaping for his life, a foreigner in this land who doesn't know the customs, doesn't know what's going on. But he can see a situation and it doesn't seem right. Musa عليه السلام has the choice to either stay away, be quiet, go and hide, not be seen — or he can try to help.

So he goes to those two women and he says: مَا خَطْبُكُمَا — "What's wrong with you?" قَالَتَا لَا نَسْقِي حَتَّى يُصْدِرَ الرِّعَاءُ — They said that we don't go to this watering hole until these men finish. They don't have the chivalry or the generosity to say to us: you're women, you go first. And we don't want to push and jostle with these men at the watering hole. So we wait — let them finish, then we'll go. وَأَبُونَا شَيْخٌ كَبِيرٌ — And we have no men to do this for us; our father is an elderly man.

So Musa عليه السلام now knows the situation. But again, he can make a choice. He can say, okay, it is what it is — and go. Or he can do something and be a key of goodness.

فَسَقَىٰ لَهُمَا ثُمَّ تَوَلَّىٰٓ إِلَى ٱلظِّلِّ فَقَالَ رَبِّ إِنِّى لِمَآ أَنزَلْتَ إِلَىَّ مِنْ خَيْرٍۢ فَقِيرٌۭ

Allah says that he went and he watered that flock of sheep for them — something that those other shepherds should have done anyway, or at least let those women go first.

Allah mentions in this passage that as a result of this single action from Musa عليه السلام — Musa who was running from oppression, didn't know where he was going, didn't know where he would hide or seek asylum, what his future would hold — Allah makes this simple act of goodness, this key of goodness, a means for him settling in Madian. He marries one of those two women, and for approximately ten years he stays there. And it is when he leaves Madian that Allah gives him revelation and makes him a Prophet. This is what the Qur'an teaches us — being a key for goodness.

The Story of Yusuf (عليه السلام) in Prison

In the story of the Prophet of Allah, Yusuf عليه السلام — when he enters into prison, two people come to him as Allah mentions:

وَدَخَلَ مَعَهُ ٱلسِّجْنَ فَتَيَانِ ۖ قَالَ أَحَدُهُمَآ إِنِّىٓ أَرَىٰنِىٓ أَعْصِرُ خَمْرًۭا ۖ وَقَالَ ٱلْءَاخَرُ إِنِّىٓ أَرَىٰنِىٓ أَحْمِلُ فَوْقَ رَأْسِى خُبْزًۭا تَأْكُلُ ٱلطَّيْرُ مِنْهُ ۖ نَبِّئْنَا بِتَأْوِيلِهِۦٓ ۖ إِنَّا نَرَىٰكَ مِنَ ٱلْمُحْسِنِينَ

Two young men approached him in prison. Yusuf عليه السلام doesn't say to them: I'm in jail, leave me alone, I have other issues to worry about. We know the story of Yusuf عليه السلام, the oppression he underwent from so many angles and directions — the difficulty, the challenges and the trials that he faced one after the other. He is in prison unjustly, being oppressed, with no valid reason to be there.

But when those two men come to him:

وَدَخَلَ مَعَهُ ٱلسِّجْنَ فَتَيَانِ ۖ قَالَ أَحَدُهُمَآ إِنِّىٓ أَرَىٰنِىٓ أَعْصِرُ خَمْرًۭا ۖ وَقَالَ ٱلْءَاخَرُ إِنِّىٓ أَرَىٰنِىٓ أَحْمِلُ فَوْقَ رَأْسِى خُبْزًۭا تَأْكُلُ ٱلطَّيْرُ مِنْهُ ۖ نَبِّئْنَا بِتَأْوِيلِهِۦٓ ۖ إِنَّا نَرَىٰكَ مِنَ ٱلْمُحْسِنِينَ

One of them said: "I see myself pressing wine in a dream." And the other one said: "I see myself being crucified and a bird coming and picking bread from my head." They said: "Interpret these dreams for us — indeed, we see that you are a righteous man."

Yusuf عليه السلام responds and tells them the meaning of the dreams. As for one of them, he will be saved from prison, leave, and become a close advisor to the king. As for the other, he will die. But Yusuf عليه السلام is also a key for goodness in another way — before he tells them the interpretation of their dreams, he teaches them about Allah. He teaches them about Tawheed. He teaches them about the religion of Ibrahim, Ismail, Ishaq, and Ya'qub عليهم السلام — his forefathers. Being a key of goodness in every single aspect of your life.

Examples from the Life of the Prophet ﷺ

The Conquest of Mecca and Abu Quhafa

When we look at the life of our Prophet ﷺ, there are countless incidents and stories where the Prophet ﷺ would be approached, or something would take place, and he was a key for goodness. Just a simple example — in the conquest of Mecca, when the Muslims came and conquered the city, the vast majority of those people living in Mecca at that time were non-Muslims. They were enemies to Islam — the likes of Abu Sufyan and his wife Hind, and Ikrimah, the son of Abu Jahl, and many others who were trying to destroy Islam and kill the Prophet ﷺ. But now the Muslims had come and conquered Mecca.

From amongst those people who was in Mecca and was not yet a Muslim was the father of Abu Bakr رضي الله عنهAbu Quhafa — an elderly man, blind from old age, his back bent because of old age, his hair and beard white because of old age. Abu Bakr رضي الله عنه went to his father, took him by the hand, and walked with him to the Prophet ﷺ.

When the Prophet ﷺ saw Abu Quhafa — the father of Abu Bakr رضي الله عنه — he knew the man was not yet a Muslim. But he saw that the man was elderly, in need, feeble, frail. So the Prophet ﷺ said to Abu Bakr: "Why didn't you leave the Shaykh at home? I would have gone to him." And then the Prophet ﷺ took the hand of Abu Quhafa and said: "Do you not testify that Allah alone is worthy of worship, and that I am the Messenger of Allah?" And Abu Quhafa took the shahada. He became a Muslim at that elderly age.

But look at the way the Prophet ﷺ was honoring him — saying, "I would have come to him; I had more right that I should go to him" — even though he was elderly, even though he was not yet a Muslim.

The Imam Who Prolonged the Prayer

The Prophet ﷺ used to be a key of goodness and would instruct his companions to stay away from things which cause harm or distress to others. We have enough of our own sins and problems to worry about without accumulating the burdens of others upon our shoulders.

When the Prophet ﷺ would see distress being caused to the Muslims — even from amongst his own companions, even in issues of ibadah and worshipping Allah, where apparently it might seem a good thing — if there was some difficulty or harm being caused, the Prophet ﷺ would speak to and advise his companions.

In the hadith of Uqba ibn Amr رضي الله عنه, he said that a man came to the Prophet ﷺ and said:

وَاللَّهِ يَا رَسُولَ اللَّهِ إِنِّي لَأَتَأَخَّرُ عَنْ صَلَاةِ الْغَدَاةِ مِنْ أَجْلِ فُلَانٍ مِمَّا يُطِيلُ بِنَا

(Sahih al-Bukhari, Hadith 702; Sahih Muslim, Hadith 466)

"O Messenger of Allah, by Allah, I delay my attendance at the prayer — I come right at the end — because of the imam so-and-so, because he prolongs his prayer too much for us." This was not in the Prophet's mosque but in another place. We know that the general rule in salah is that when you pray at home alone, the longer your salah, the better — the greater reward in the sight of Allah. But when there are people behind you praying in congregation and you don't know each person's individual situation, their issues, their appointments, what they have to do — مِمَّا يُطِيلُ بِنَا — this imam makes the prayer too long.

The narrator of the hadith said: مَا رَأَيْتُ رَسُولَ اللَّهِ ﷺ فِي مَوْعِظَةٍ أَشَدَّ غَضَبًا مِنْهُ يَوْمَئِذٍ — "I never saw the Prophet ﷺ more angry in a sermon than on that day." And he said to the people:

إِنَّ مِنْكُمْ مُنَفِّرِينَ، فَأَيُّكُمْ أَمَّ النَّاسَ فَلْيَتَجَوَّزْ، فَإِنَّ فِيهِمُ الضَّعِيفَ وَالْكَبِيرَ وَذَا الْحَاجَةِ

(Sahih al-Bukhari, Hadith 702; Sahih Muslim, Hadith 466)

"From amongst you are those who turn others away from Allah. This man is the imam — he's leading them in prayer and prolonging the salah. So if one of you wants to be the imam, let him make the prayer shorter, because behind him there are the elderly, and the sick, and those people who have other things to do — they have jobs, they have appointments, they have things that they need to go and busy themselves with."

A Welcoming Approach in the Masjid

We have people — and inshallah this is a masjid that is welcoming — but even in issues of ibadah, if you see someone in this masjid, whether in the men's hall or the women's hall, and they are a new person, a new face to you, and perhaps they are making a mistake or not dressed appropriately — there is a way to approach them and be a key of goodness, and there is a way to approach them and be a lock upon goodness.

The Prophet ﷺ is instructing and teaching the companions: be careful in the way that you approach people. Recall the hadith of the Bedouin man who came into the masjid of the Prophet ﷺ and went to the corner and began to urinate. The Prophet ﷺ calmed his companions who became angry when they saw this — and rightly so, for it was the masjid, the house of Allah, and not just any house of Allah, but the masjid of our Prophet ﷺ in Medina. But the Prophet ﷺ calmed them down and said: let him finish. And when he finished, he told them to find water and go and clean it. And he called the man and said to him: these are the houses of Allah. They are for salah, for prayer, and for Qur'an, and for the remembrance of Allah. It is not befitting that you do what you just did in a place like this.

That man was so amazed by the character and conduct of the Prophet ﷺ that he said: "O Allah, forgive me and forgive Muhammad. Have mercy upon me and upon Muhammad ﷺ." Because the Prophet ﷺ handled a situation — even though people had told the man off, and perhaps they would have been within their rights, and perhaps most people would have accepted that — in a way that not only stopped the evil but transformed it into a means of goodness, teaching and educating the people.

Mu'adh ibn Jabal and the Long Prayer

In another hadith collected by al-Nasa'i, it is narrated that Mu'adh ibn Jabal رضي الله عنه — the great illustrious companion of the Prophet ﷺ, one of the most noble and most knowledgeable companions of that time — used to pray salah with the Prophet ﷺ in Masjid al-Nabawi. He would pray the Isha prayer in congregation and then leave and go to Quba', which in those days was on the outskirts of Medina. He would go and be the imam for his own people — they wouldn't pray until Mu'adh came back. When Mu'adh would come, even though he had already prayed, he would lead them as their imam in a nafl prayer, and they would pray Isha behind him.

One night the Prophet ﷺ delayed the Isha prayer. The custom was that the Prophet ﷺ would wait for the people to gather from their jobs and their work. If they gathered earlier, he would pray early. If they were slower, he would wait until they gathered and then pray. So one night the prayer was delayed. Mu'adh prayed in Medina and then went to Quba' and began to pray Isha — and he started reciting Surah al-Baqarah, the longest surah of the Qur'an.

A man who was praying behind him left the salah, broke his prayer, went to the corner of the masjid, prayed his own Isha, and went home. Someone met him after the salah and said: "Have you committed hypocrisy?" He said: "No, by Allah, I haven't committed hypocrisy. But I will go to the Prophet ﷺ and tell him what took place." So the next day he came to Medina and said: "O Messenger of Allah, Mu'adh prays Isha with you. And then when he comes back — especially when the Isha is delayed — he prays with us as imam and recites Surah al-Baqarah. So I left the salah and prayed my own prayer and went home, because I am a shepherd and a farmer. I wake up early in the morning and have work to do."

So the Prophet ﷺ called Mu'adh and said: "أَفَتَّانٌ أَنْتَ يَا مُعَاذُ — O Mu'adh, do you wish to cause fitna for the people? Do you wish to cause people trials within their religion? But rather, O Mu'adh, when you lead, recite such and such a surah." And the Prophet ﷺ told him the types and lengths of surahs he should recite. The Prophet ﷺ didn't say anything to the man who had broken his prayer and went home — because he had a valid reason. And the Prophet ﷺ was instructing Mu'adh رضي الله عنه that he needs to be aware of the situation of the people.

Be a key for goodness and a lock upon evil. That is what Allah has instructed us to be. That is what we find within the surahs and the stories of the Qur'an, and within the life and the examples of our Prophet ﷺ.

May Allah make us all a key of good and a lock upon evil. إِنَّهُ هُوَ الْغَفُورُ الرَّحِيمُ

Wanting Genuine Good for Others

From amongst the components of this hadith and the meanings of these words of our Prophet ﷺ: being a key for goodness is wanting good for others. When you advise someone, or when you see someone making a mistake and you speak to them, do so with the intention that you want goodness for them — that you want khair for them, that you want benefit for them. The point of advising people, of speaking out when you see mistakes, of even just meeting and interacting with other people is not to put them down, disgrace them, or humiliate them — but rather it is to seek and want genuine goodness for them. That is your intention, first and foremost.

Al-Imam Al-Shafi'i رحمه الله said that he never debated with another person except that he wanted Allah to bring the truth upon his brother's tongue — not upon his own tongue — because he wanted good for his brother just as he wanted good for himself.

Do Not Rejoice at the Downfall of Fellow Muslims

From the components and meanings of this hadith of the Prophet ﷺ: when you see people — especially your fellow Muslims, your brothers and sisters — being attacked in any way, shape, and form, you are not happy and you do not rejoice that they are being put down. We live in a time now when many people are attacking Islam, and the way that they attack Islam is that they attack certain groups — this group because of the way that they dress, this group because of the way that they act, that group because of the way that they do something. And even though we may have valid differences with people in terms of their beliefs, at the same time we do not rejoice when we see other Muslims being put down — because today it is them, and tomorrow it will be us.

Amongst the Arabs there is a famous story of the three bulls — a black bull, a white bull, and a red bull. A lion wanted to eat them but couldn't take on all three. So he went to two of the bulls and said: "I don't want you — I want the white bull. Leave me alone, let me take the white bull, and I'll leave you alone." They agreed — better he takes him than us. So the lion went and killed and ate the white bull.

But after a few days he became hungry again. This time he wanted the other two — the red and the black. Again, he could not take both of them down. So he went to the black bull and said: "I don't want you — I want the red one. Leave me alone and I'll leave you alone." The black bull said: "Okay — better him than me." So the lion went and ate the red bull. But a lion being a lion, after a few more days, came back hungry. And now it cornered the black bull alone — no friends to help it, no one to come to its aid. When this bull saw what had come to pass, it said: "I died the day the white bull died. The day that I gave up my principles, the day I let you eat that white bull — that's the day I sealed my own fate."

So we as Muslims need to understand: being a key of goodness means that you want good for the people. And when they make mistakes, there is a way and a manner in which to advise them, in which you bring them closer to goodness. Whenever you call someone out and disgrace them and humiliate them publicly — we will never accept this from anyone, so why would anyone else accept it from us? There is hikmah in the way that the Prophet ﷺ used to correct people, the way he used to speak to people, the way he used to advise people.

The Janazah Hadith: Your Legacy Among the People

I want to leave you with a final hadith — a hadith narrated by Abu Hurairah رضي الله عنه — that the Prophet ﷺ was sitting with his companions and they saw a janazah, a funeral procession, go past them. The people began to praise the deceased person and speak of them in terms of goodness. So the Prophet ﷺ said:

وَجَبَتْ، وَجَبَتْ، وَجَبَتْ
الْمَلَائِكَةُ شُهَدَاءُ اللَّهِ فِي السَّمَاءِ وَأَنْتُمْ شُهَدَاءُ اللَّهِ فِي الْأَرْضِ

(Sahih al-Bukhari, Hadith 1367; Sahih Muslim, Hadith 949)

"It has been written, it has been written, it has been written." Then after a while, another funeral procession, another janazah passed by. But this time the people didn't have glowing terms to speak of about that person — they didn't say anything good. So the Prophet ﷺ again said: "It has been written, it has been written, it has been written."

Umar رضي الله عنه said: "O Messenger of Allah, a janazah went past and the people praised it, and you said it's been written. Then a janazah went past and the people didn't say anything good, and you said it's been written. What has been written?" The Prophet ﷺ said: "Your words, your testimony for those people — it had been written. The angels of Allah are the witnesses of Allah in the heavens. And you — the people — you are the witnesses of Allah upon this earth."

When people speak of you in good terms because of the goodness that you bring to others, that is inshallah a sign of goodness for you. But if the people don't have anything good to speak of about you, then that is something that should cause alarm bells to ring — it should make you stop and think about the way that you are.

Be a key of goodness, a lock upon evil, and seek refuge in Allah from being a key of evil and a lock upon goodness.

Du'a

We ask Allah that He showers His blessings upon us and our community, and that Allah keeps us firm upon the straight path, and that Allah protects us and our children and our families and our community from every type of trial — whether great or small, whether apparent or hidden. We ask Allah that He showers His mercy and blessings upon us, that He forgives us for our sins, that He enters us into the highest ranks of Jannah. We ask Allah on this blessed day of Jumu'ah that He relieves the distress of our brothers and sisters across the world, and that Allah makes their affairs easy for them, that Allah cures those from amongst us who are ill, and that He forgives and has mercy upon those from amongst us who have passed away.

سُبْحَانَ رَبِّكَ رَبِّ الْعِزَّةِ عَمَّا يَصِفُونَ وَسَلَامٌ عَلَى الْمُرْسَلِينَ وَالْحَمْدُ لِلَّهِ رَبِّ الْعَالَمِينَ