The Messenger of Allah ﷺ said, "The plague is a punishment that was sent upon a group of the Children of Israil, or upon those who came before you. So when you hear of it in a land, do not enter it, and when it breaks out in a land where you are, do not leave fleeing from it."
سمع عامر بن سعد بن أبي وقاص أباه سعد بن أبي وقاص يسأل أسامة بن زيد: ما سمعت من رسول الله ﷺ في الطاعون؟
قال رسول الله ﷺ: الطاعون رجز أرسل على طائفة من بني إسرائيل- أو على من كان قبلكم- فإذا سمعتم به بأرض فلا تدخلوا عليه، وإذا وقع بأرض وأنتم بها فلا تخرجوا فرارا منه.
Malik narrated it in the book of Jami (23), from Muhammad bin Munkadir, and from Salim bin Abu Nadr, the freed slave of Umar bin Ubaydullah, from Amir bin Saad bin Abu Waqqas, narrating it as mentioned. Bukhari narrated it in the book of Prophets (3473), and Muslim in the book of Greetings (2218:92), via Malik, with the same wording.Bukhari also narrated it in the book of Medicine (5728), and Muslim in the book of Medicine (2218:97), via Shubah, from Habib bin Abu Thabit, who said,"We were in Madinah, and news reached me that the plague had broken out in Kufa. Ata bin Yasar and others said to me, 'The Messenger of Allah said, "If you are in a land and the plague breaks out there, do not leave it, and if you hear that it has broken out in a land, do not enter it."' I said, 'From whom?' They said, 'Amir bin Saad relates it.' So I went to him, but they said he was away. Then I met his brother Ibrahim bin Saad and asked him. He said, 'I was present when Usama was narrating to Saad. He said, I heard the Messenger of Allah say, "This affliction is a punishment," or "a punishment," or "the remnant of a punishment with which people before you were punished. So if it occurs in a land where you are, do not leave it, and if you hear that it has occurred in a land, do not enter it."'"Habib said, "I said to Ibrahim, Did you hear Usama narrating this to Saad while he did not deny it?" He said, "Yes."The wording given is Muslim's, and Bukhari does not include this story. Rijz means punishment.