Although this prayer was not in the pen of camels, it was near a camel, and it was nevertheless valid because the place was pure; just as in another hadith praying near a devil is disliked, yet when a devil passed by him (peace and blessings be upon him) during prayer and he (peace and blessings be upon him) squeezed its throat, his (peace and blessings be upon him) prayer was not invalidated. And Allah knows best.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الصلاة / 4363