Moving while Praying
Question

Some people fiddle with their clothes, clean their nails or look at their watches etc whilst praying, especially when the imam is reciting. This often provokes feelings of annoyance among the worshippers standing next to them. What is the ruling on that?
Praise be to Allah.Types of moving while praying
Shaykh Ibn ‘Uthaymin (may Allah have mercy on him) stated that the basic ruling on moving while praying is that it is makruh unless it is done for a reason. However it may be divided into five categories: 

Obligatory movements
Forbidden movements
Makruh movements
Mustahabb movements
Permissible movements

Obligatory movements in prayer
The obligatory movements are those on which the validity of the prayer depends. For example if a person notices something impure on his ghutrah (head gear), he has to move to remove it and take off his ghutrah. That is because Jibril came to the Prophet (peace and blessings of Allah be upon him) when he was leading the people in prayer and told him that there was something dirty on his shoe. So the Prophet (peace and blessings of Allah be upon him) took it off while he was praying and carried on praying. (Narrated by Abu Dawud, 650; classed as sahih by al-Albani in al-Irwa, 284)
Or if someone tells him that he is not facing the qiblah, he should move to face the qiblah. 
Forbidden movements in prayer
The forbidden movements are continuous movements done for no reason, because this kind of movement invalidates the prayer, and whatever invalidates the prayer is not permissible, because it is like mocking the signs of Allah. 
Mustahabb movements in prayer
The mustahabb movements are those done in order to do things that are mustahabb in prayer, such as if a person moves to make the row straight, or if he sees a gap in the row in front, so he moves forward whilst praying, or if there is a gap in his row and he moves to fill the gap and other such movements which allow one to do a deed that is mustahabb in prayer, because that makes the prayer more perfect and complete. Hence when Ibn 'Abbas (may Allah be pleased with him) prayed with the Prophet (peace and blessings of Allah be upon him) and stood to his left, the Messenger of Allah (peace and blessings of Allah be upon him) took hold of his head from behind and made him stand on his right. (Agreed upon) 
Permissible movements n prayer
The permissible movements are small movements done when there is a reason, or large movements done in cases of necessity. Small movements done for a reason are like what the Prophet (peace and blessings of Allah be upon him) did when he was praying and he carried Umamah, the daughter of Zaynab the daughter of the Messenger of Allah (peace and blessings of Allah be upon him), whose maternal grandfather he was. When he stood up he picked her up, and when he prostrated he put her down. Al-Bukhari, 5996; Muslim, 543. 
Large movements in cases of necessity include praying while fighting. Allah says (interpretation of the meaning): 
“Guard strictly (five obligatory) As-Salawat (the prayers) especially the middle Salah (i.e. the best prayer - ‘Asr). And stand before Allah with obedience [and do not speak to others during the Salah (prayers)].
239. And if you fear (an enemy), perform Salah (pray) on foot or riding. And when you are in safety, offer the Salah (prayer) in the manner He has taught you, which you knew not (before).” [al-Baqarah 2:238-239]
If a person prays while walking he is undoubtedly moving a great deal, but in cases of necessity that is permitted and does not invalidate the prayer. 
Makruh movements in prayer
The makruh movements are all movements other than those mentioned above. This is the basic principle concerning movements while praying.
How much movement invalidates the prayer
Based on this, we say to those who move whilst praying that their action is makruh and detracts from their prayer. This is something that is seen in many cases, so you may see a person fiddling with his watch or pen or ghutrah or nose or beard and so on. All of that comes under the heading of makruh, unless it is done a great deal and is continuous, in which case it is haram and invalidates the prayer. 
Shaykh Ibn ‘Uthaymin (may Allah have mercy on him) also stated that there is no specific number of movements that invalidates the prayer, rather it is any movement that contradicts the idea of prayer in the sense that if anyone saw this man doing that it would look as if he were not praying. This is the kind of movement that invalidates the prayer. Hence the scholars (may Allah have mercy on them) defined it as something based on custom (al-‘urf) and said: “If movements are many and are continuous, then they invalidate the prayer without mentioning a specific number. Some scholars defined three such movements but that requires evidence because everyone who sets a certain limit or number or manner should produce evidence, otherwise he is introducing new ideas.” (Majmu’ Fatawa al-Shaykh, 13/309-311) 
Shaykh ‘Abd al-‘Aziz ibn Baz (may Allah have mercy on him) was asked about a man who moved a great deal whilst praying: did that invalidate his prayer and how could he rid himself of this habit? 
He (may Allah have mercy on him) replied: 
“The Sunnah is to focus on one’s prayer with proper humility, body and soul, whether it is an obligatory prayer or a nafl prayer, because Allah says (interpretation of the meaning): 
“Successful indeed are the believers. Those who offer their Salaah (prayers) with all solemnity and full submissiveness.” [Al-Muminun 23:1-2]
He must pray in a tranquil and dignified manner. This is one of the most important pillars and obligations of prayer, because the Prophet (peace and blessings of Allah be upon him) said to one who prayed badly and was not tranquil and dignified in his prayer: “Go back and pray for you have not prayed.” And he did that three times. Then the man said: “O Messenger of Allah, by the One Who sent you with the truth, I cannot do any better than this, teach me.” The Prophet (peace and blessings of Allah be upon him) said: “When you stand up to pray, do wudu well, then turn to face the qiblah and say takbir, and recite whatever you can of the Quran. Then bow until you are at ease in bowing, then raise your head until you are standing up straight. Then prostrate until you are at ease in prostration, then sit up until you are sitting up straight and are at ease in sitting. Then prostrate until you are at ease in prostration, then get up until you are standing up straight. Then do that throughout your prayer.” (Agreed upon)  
According to a version narrated by Abu Dawud, he said: “Then recite the Essence of the Quran (al-Fatihah) and whatever Allah wills.” 
This sahih hadith indicates that being at ease in the postures is a pillar or essential part of the prayer, and an important obligation, without which prayer is not valid. Whoever pecks out his prayer (by moving too rapidly), there is no prayer for him. Khushu` (proper focus and humility) is the essence of prayer. It is prescribed for the believer to pay attention to that and strive to achieve it. 
With regard to defining the movements that contradict this ease and focus in prayer and limiting them to three movements, there is no hadith from the Prophet (peace and blessings of Allah be upon him) to support this idea. Rather that is the suggestion of some scholars for which there is no reliable evidence. 
But it is makruh to fidget during the prayer, such as touching one's nose, beard or clothes and being distracted by that. Fidgeting a great deal invalidates the prayer. But if it is done a little, according to what is customary, or is done a great deal but is not continuous, then the prayer is not invalidated thereby. But it is prescribed for the believer to maintain proper focus and humility, and to avoid fidgeting a little or a lot, and to strive to make his prayer perfect. 
The evidence that small movements, or repeated movements that are not continuous, do not invalidate the prayer is the report which says that the Prophet (peace and blessings of Allah be upon him) opened the door for ‘Aishah one day whilst he was praying. Narrated by Abu Dawud, 922; al-Nasai, 601; classed as sahih by Shaykh al-Albani in Sahih al-Tirmidhi, 601.  
And it was proven in the hadith of Abu Qatadah (may Allah have mercy on him) that the Prophet (peace and blessings of Allah be upon him) led the people in prayer one day when he was carrying Umamah the daughter of Zaynab. When he prostrated he put her down and when he stood up he picked her up.” (Fatawa ‘Ulama al-Balad al-Haram, 162-164)
For more, please see these answers: 87749 , 146675 , 8673 , 135372 , 326070 , and 190016 .
And Allah knows best.