"he used to stand (in prayer) bare-footed sometimes and wearing shoes sometimes."28
he allowed this for his ummah, saying: when one of you prays, he should wear his shoes or take them off and put them between his feet, and not harm others with them.29
he encouraged prayer wearing them sometimes, saying: be different from the jews, for they do not pray in their shoes nor in their khuffs (leather socks).30
occasionally he would remove them from his feet while in prayer and then continue his prayer, as abu sa'eed al-khudri has said:
"the messenger of allaah (sallallaahu 'alaihi wa sallam) prayed with us one day. whilst he was engaged in the prayer he took off his shoes and placed them on his left. when the people saw this, they took off their shoes. when he finished his prayer he said, why did you take your shoes off? they said, 'we saw you taking your shoes off, so we took our shoes off.' he said, verily jibreel came to me and informed me that there was dirt - or he said: something harmful - (in another narration: filth)on my shoes, so i took them off. therefore, when one of you goes to the mosque, he should look at his shoes: if he sees in them dirt - or he said: something harmful - (in another narration: filth) he should wipe them and pray in them.31
"when he removed them, he would place them on his left"32 and he would also say: when one of you prays, he should not place his shoes on his right nor on his left, where they will be on someone else's right, except if there is no one on his left, but he should place them between his feet.33
28 abu daawood & ibn maajah. it is a mutawatir hadeeth as tahaawi has mentioned.
29 abu daawood & bazzaar (53, az-zawa'id); haakim declared it saheeh and dhahabi agreed.
31 abu daawood, ibn khuzaimah & haakim, who declared it saheeh and dhahabi and nawawi agreed. the first one is given in irwaa' (284)
33 abu daawood, nasaa'i & ibn khuzaimah (1/110/2) with a saheeh isnaad.