Language:
كتاب القدر
82  
Divine Will (Al-Qadar)
(15)
Chapter: "Say: 'Nothing shall ever happen to us except what Allah has ordained for us ...'"
(15)
Sahih al-Bukhari 6619

Narrated `Aisha:

I asked Allah's Messenger (ﷺ) about the plague. He said, "That was a means of torture which Allah used to send upon whom-so-ever He wished, but He made it a source of mercy for the believers, for anyone who is residing in a town in which this disease is present, and remains there and does not leave that town, but has patience and hopes for Allah's reward, and knows that nothing will befall him except what Allah has written for him, then he will get such reward as that of a martyr."

حَدَّثَنِي إِسْحَاقُ بْنُ إِبْرَاهِيمَ الْحَنْظَلِيُّ، أَخْبَرَنَا النَّضْرُ، حَدَّثَنَا دَاوُدُ بْنُ أَبِي الْفُرَاتِ، عَنْ عَبْدِ اللَّهِ بْنِ بُرَيْدَةَ، عَنْ يَحْيَى بْنِ يَعْمَرَ، أَنَّ عَائِشَةَ ـ رضى الله عنها ـ أَخْبَرَتْهُ أَنَّهَا، سَأَلَتْ رَسُولَ اللَّهِ صلى الله عليه وسلم عَنِ الطَّاعُونِ فَقَالَ ‏ "‏ كَانَ عَذَابًا يَبْعَثُهُ اللَّهُ عَلَى مَنْ يَشَاءُ، فَجَعَلَهُ اللَّهُ رَحْمَةً لِلْمُؤْمِنِينَ، مَا مِنْ عَبْدٍ يَكُونُ فِي بَلَدٍ يَكُونُ فِيهِ، وَيَمْكُثُ فِيهِ، لاَ يَخْرُجُ مِنَ الْبَلَدِ، صَابِرًا مُحْتَسِبًا، يَعْلَمُ أَنَّهُ لاَ يُصِيبُهُ إِلاَّ مَا كَتَبَ اللَّهُ لَهُ، إِلاَّ كَانَ لَهُ مِثْلُ أَجْرِ شَهِيدٍ ‏"‏‏.‏
Reference : Sahih al-Bukhari 6619
In-book reference : Book 82, Hadith 25
USC-MSA web (English) reference : Vol. 8, Book 77, Hadith 616
  (deprecated numbering scheme)