Ibn Abbas said, regarding the words of Allah the Exalted "And do not be loud in your prayer, nor be silent in it" [Isra 17:110], that it was revealed while the Messenger of Allah ﷺ was in hiding in Makkah. When he prayed with his companions he would raise his voice with the Quran, and when the polytheists heard it they would insult the Quran, and the One who sent it down, and the one who brought it.So Allah said to His Prophet ﷺ, "And do not be loud in your prayer" [Isra 17:110], meaning in your recitation, so that the polytheists hear it and insult the Quran, "nor be silent in it" [Isra 17:110], keeping it from your companions so that they cannot hear you, "but seek a way between that" [Isra 17:110].
حدثني عمرو بن زرارة عن هشيم أخبرنا أبو بشر
عن ابن عباس رضي الله عنهما في قوله تعالى {ولا تجهر بصلاتك ولا تخافت بها} قال نزلت ورسول الله ﷺ مختف بمكة فكان إذا صلى بأصحابه رفع صوته بالقرآن فإذا سمعه المشركون سبوا القرآن ومن أنزله ومن جاء به فقال الله لنبيه ﷺ {ولا تجهر بصلاتك} أي بقراءتك فيسمع المشركون فيسبوا القرآن {ولا تخافت بها} عن أصحابك فلا تسمعهم {وابتغ بين ذلك سبيلا}