This was revealed while the Messenger of Allah ﷺ was still in hiding at Makkah. Whenever he prayed with his companions he would raise his voice in reciting the Quran, and when the idolaters heard it they would revile the Quran, the One who sent it down, and the one who brought it. So Allah Most High said to His Prophet, "And do not be loud in your prayer" [Isra 17:110], meaning in your recitation, so that the idolaters hear it and revile the Quran, "nor be too quiet in it" [Isra 17:110], that is, from your companions, so that they cannot hear you, "but seek a way between that" [Isra 17:110].
في قوله تعالى: {ولا تجهر بصلاتك ولا تخافت بها} [سورة الكهف: ١١٠]
نزلت ورسول الله ﷺ مختف بمكة، كان إذا صلى بأصحابه رفع صوته بالقرآن، فإذا سمع المشركون سبوا القرآن، ومن أنزله، ومن جاء به فقال الله تعالى لنبيه: {ولا تجهر بصلاتك} أي بقراءتك، فيسمع المشركون فيسبوا القرآن {ولا تخافت بها} عن أصحابك فلا تسمعهم {وابتغ بين ذلك سبيلا}.
Bukhari related it in the tafsir (4722), and Muslim in the prayer (446), both from the hadith of Hushaym, who said, our teacher Abu Bishr (that is, Jafar bin Iyas) told us, from Saeed bin Jubayr, from Ibn Abbas, and he mentioned it.And from Ayesha, concerning the words of Allah Most High, "Do not say your prayer aloud, nor say it silently" [Isra 17:110], she said, this was revealed concerning supplication. Bukhari related it in the tafsir (4723), and Muslim in the prayer (447), both from the hadith of Hisham, from his father, from Ayesha, and she mentioned it, and their wording is the same.