Anas bin Malik reported,

The Prophet ﷺ was delivering the Friday sermon when the people stood up and cried out, "Messenger of Allah, the rain has stopped, the trees have turned red, and the livestock are perishing. Pray to Allah to give us rain."He said twice, "O Allah, give us rain." By Allah, we could not see a single wisp of cloud in the sky. Then a cloud formed and it began to rain. He came down from the pulpit and prayed, and after he finished, the rain continued until the following Friday.When the Prophet ﷺ stood up to deliver the sermon the next Friday, the people cried out to him, "The houses have collapsed and the roads have been cut off. Pray to Allah to hold it back from us."The Prophet ﷺ smiled and said, "O Allah, around us and not upon us." The clouds were stripped away from Medina and began to rain around it, while not a drop fell on Medina itself. I looked at Medina and it was encircled like a crown.

Bukhari 1021

Sahih

حدثنا محمد بن أبي بكر حدثنا معتمر عن عبيد الله عن ثابت

عن أنس بن مالك قال

كان النبي ﷺ يخطب يوم جمعة فقام الناس فصاحوا فقالوا يا رسول الله قحط المطر واحمرت الشجر وهلكت البهائم فادع الله يسقينا فقال اللهم اسقنا مرتين وايم الله ما نرى في السماء قزعة من سحاب فنشأت سحابة وأمطرت ونزل عن المنبر فصلى فلما انصرف لم تزل تمطر إلى الجمعة التي تليها فلما قام النبي ﷺ يخطب صاحوا إليه تهدمت البيوت وانقطعت السبل فادع الله يحبسها عنا فتبسم النبي ﷺ ثم قال اللهم حوالينا ولا علينا فكشطت المدينة فجعلت تمطر حولها ولا تمطر بالمدينة قطرة فنظرت إلى المدينة وإنها لفي مثل الإكليل

البخاري 1021صحيح
Contents
Reference
Commentary
Ayat
Collection
Sahih Bukhari
Book
Istisqa
Chapter
Supplication when rain becomes excessive, "Around us and not upon us"
Numbering
Darussalam 1021
Bukhari 1021