Short answer
Yes, if the shoes are clean of najasah (impurity) and your toes can press toward the ground in sajdah. The Prophet ﷺ prayed in his sandals. But do not wear outdoor shoes on a masjid's carpet; that harms the masjid and its worshippers. The four schools agree it is permissible.
Praying in pure shoes is permissible. If impurity is on them, the prayer is not valid until it is removed. In sajdah the toes of at least one foot must touch the ground, so footwear that stops the toes from bending is a problem. In carpeted masjids, shoes should be removed out of respect and cleanliness.
The four schools agree on this.
Explanation
The four schools agree that praying in shoes or sandals is allowed. Anas was asked whether the Prophet ﷺ prayed in his sandals and he said yes. Another hadith tells Muslims to pray in their footwear to differ from those who did not. On the other hand, he once took off his sandals during prayer when Jibril told him there was dirt on them, which shows that the shoes must be clean.
- Purity: if there is najasah such as dog mess or urine on the sole, remove the shoes or clean them first.
- Sajdah: in the Hanafi school your toes, at least of one foot, should press on the ground facing the qibla. Soft trainers usually allow this; stiff boots may not.
- Masjid carpets: do not walk on them in outdoor shoes. Masjids today are carpeted, and dirt carried on shoes would harm the place people put their faces. Follow the masjid's rules.
- Outdoors, a park, a hospital or work: praying in clean shoes is fine and saves time.
Socks are of course fine. If you have made wudu with wiping over leather socks (khuffs), you may pray in them as usual; see the guide on how to make wudu.
The evidence
Sahih al-Bukhari 386
Sahih... أكان النبي صلى الله عليه وسلم يصلي في نعليه قال نعم ...
"Did the Prophet pray in his sandals? He said: Yes."
Praying in footwear is permissible.
Sunan Abi Dawud 652
Graded sahih... خالفوا اليهود فإنهم لا يصلون في نعالهم ولا خفافهم ...
"Differ from the Jews, for they do not pray in their sandals or their leather socks."
Praying in clean footwear is allowed and was encouraged.
Sunan Abi Dawud 650
Graded sahih... إن جبريل صلى الله عليه وسلم أتاني فأخبرني أن فيهما قذرا ...
"Jibril came to me and told me there was dirt on them."
Shoes with impurity on them must be removed.
Where the ruling is recorded
- Radd al-Muhtar (Ibn Abidin), Chapter on what is disliked in prayer. Praying in pure sandals is permissible, and the masjid is protected from dirt.
- Nur al-Idah with Maraqi al-Falah, Chapter on the wajibat and description of prayer. Placing the toes on the ground in sajdah.
This answer is pending review by the scholars on our team. Quran translation by Sahih International. Hadith Arabic from the standard editions of the six books and the Muwatta, with gradings as recorded there; the English is our own rendering. Spotted a mistake? Tell us.