It is a well established custom to sway (shukel) during prayer (teffilah) and Torah study. The following questions will be addressed on this topic:
§ Is shukeling only for teffilah or is it also for learning Torah?
§ What are the reasons to shukel?
§ What are the reasons not to shukel?
§ Assuming one is permitted to shukel, what type of shukeling is allowed?
§ What is the practical Halacha? 
Is shukeling only for teffilah or is it also for Torah learning?
The consensus of the majority of opinions is that one may (or perhaps should) shukel during Torah learning and all parts of prayer (with the possible exception being that of Shemoneh Esrei). Concerning Torah learning, the commentators say the following:
Ba’al ha-turim, Ex. 20:15, on the verse, “the people saw and trembled” comments, “Therefore we sway during Torah learning (limud ha-Torah), since the Torah was given with fear, terror, and shaking (b-aimah, reses, and zeiah).”
Darchei Moshe, commenting on Tur, Hilchos Birchas ha-Shachar 48:1, cites Abudraham, “…the custom of Israel is to shake while they read (b’sha’a shekorin) just like when the Torah was given, it was given with terror…” The phrase b’sha’a shekorin refers to the time the Torah is being read in the synagogue. Rama, Shulchan Aruch ad loc. comments, “…the custom of those that are careful is to sway while the Torah is being read, comparable to the Torah that was given with terror.”
Aruch ha-Shulchan, 48:3, says, “Rama writes that ‘those who are careful have the custom to shake while the Torah is being read comparable to the Torah that was given with terror’…[the reason is because] Torah is called a fire, and fire is constantly shaking.”
In case the reader finds the latter three sources unconvincing as they do not mention shukeling while learning Torah but only while the Torah is being read, two more sources will be provided later.
Where does the idea of shukeling come from? Should one shukel during Shemoneh Esrei?
The most common reason cited by the commentators is Psalms 35:10, kol atzmosai tomarnah Hashem mi kamocha – All my bones shall say: ‘HaShem, who is like You’.
Sefer Chasidim, 57 says, “a person needs (tzarich) to shake his entire body during teffilah since the verse says kol atzmosai tomarnah Hashem mi kamocha.” It should be noted that the word teffilah connotes Shemoneh Esrei.
Shibolei HaLeket, 17 cites Ma’aseh Merkava as follows, “during teffilah a person needs to shake his entire body since the verse says kol atzmosai tomarnah Hashem mi kamocha.”
Matte Moshe, 118 says, “A person needs to shake himself during teffilah since the verse says kol atzmosai tomarnah Hashem mi kamocha.”
Darchei Moshe ibid, continuing to cite Abudraham states “a further reason [to shukel] is based on the verse kol atzmosai tomarnah Hashem mi kamocha.” 
Rama, ibid, ends, “…[those that are careful will shake] also during teffilah (b’sha’a she-mispallilim) based on the verse kol atzmosai tomarnah Hashem mi kamocha.” Aruch ha-Shulchan ibid, quotes this Rama.
Shulchan Aruch, Mechaber, 95:3 states as follows, “[during Shemoneh Esrei one should] stand like a slave before his master with fear, awe, and dread (aimah, yirah, pachad).” Mishnah Berurah 7, comments on this, “‘With fear’, and there are some that shake during teffilah based on the verse kol atzmosai tomarnah Hashem mi kamocha.”
Others offer different interpretations as to the source of shukeling.
Kuzari 2:79-80 offers two rational approaches to swaying. The following is a translation of Kuzari :
“Kuzari: I should like to ask whether you know the reason why Jews move back and forth when reading Hebrew (kre’ats ha-ivris)?
The Rabbi: It is said that it is done in order to arouse natural heat. [But I reject this idea]. My personal belief is that…it often happened that many persons read at the same time, [so much so that] it was possible that ten or more read from one volume. This is the reason why our books are so large. Each of them was obliged to bend down in his turn in order to read a passage, and to turn back again. This resulted in a continual bending and sitting up, the book lying on the ground. This was one reason. Then it became a habit through constant seeing, observing and imitating, which is in man’s nature. Other people read each out of his own book, either bringing it near to his eyes, or, if he pleased, bending down to it without inconveniencing his neighbor. There was, therefore, no necessity of bending and sitting up.”
We see from here that two types of groups developed; those that were not affluent enough to have their personal books – they began to sway, and those who were privileged to possess their own books – and therefore never acquired the habit of shukeling .
Rivash, quoted by Mekor Chesed on Sefer Chasidim, ibid. gives a parable that when one is drowning and jumping around in the water, people won’t make fun of him. So too, when one is davening and shaking himself, he is attempting to remove distractions. “When a man is drowning in a river and making many movements to remove himself from the water, surely those that are watching him will not laugh at him and his [strange] movements; so too, when one prays (k’she’mispallel) and makes many [strange] movements, one should not laugh at him.” This source seems to indorse the more animated type shukeling that one sees from Chasidim.
R’ Schwab provides his own understanding of shukeling in R’ Schwab on Prayer (page 167):
“There are two ways in which a person can relate to Hakodosh Baruch Hu. One is through ahava (love), in which a person feels very close to Him, and the other is through yirah (awe), in which one is awestruck by His Omnipotence and Omniscience. This may explain the ancient Jewish practice of “shokeling,” swaying forward and backward during teffilah. The forward motion expresses one’s desire to come close to Hakodosh Baruch Hu, but then, upon reflection, one realizes that He is the Ribbono Shel Olam, the Master of the universe, which causes one to reel back in awe. These thoughts are typically evoked during meditation.”
What are reasons not to shukel during Shmoneh Esrei ?
Ba’al Shem Tov, quoted by Mekor Chesed, ibid. states that one may shukel – but not during Shmoneh Esrei . “Teffilah (i.e. Shmoneh Esrei) is like being paired with the Divine Presence…therefore, one must shake himself at the beginning [of prayer]. After this (i.e. during Shmoneh Esrei) one is able to stand without movement. [This is because] he will be connected with the Divine Presence with a great connection.”
Perush Azulai on Sefer Chasidim, ibid. says one should not shukel during Shmoneh Esrei. “Rabbi and Kabbalist Yisroel Saruk and his student Ramah, may their memories be blessed, write that one should not shake his body during the recitation of Shmoneh Esrei since it (Shmoneh Esrei) is like standing before the King.”
The most stringent source against shukeling during Shmoneh Esrei is Shlah (quote found in Nesiv Binah, vol. 1, pg. 96). He emphatically states that not moving will give one more concentration. He proves it by saying that nobody has ever gone to a king to ask for something while shaking – kal v’chomer before Hashem. “Standing without any movement at all [during Shmoneh Esrei] will help one concentrate. The verse that states kol atzmosai tomarnah (and is a source for shukeling) is only in reference to shiros, tishbachos, blessings on Shema, and during Torah learning  – but not during Shmoneh Esrei. If somebody should challenge you and say that one should also sway during Shmoneh Esrei, it would appear to me that such a person should be ignored. Ones own experience will prove that standing without any movement at all during Shmoneh Esrei will cause ones heart to concentrate. One should check it out himself: would a person ever ask requests from a human king while his body is swaying like the trees in the forest due to the wind?!”
What forms of shukeling are not permitted?
Maharil, Hilchos Teffilah, 2, states that Maharil used to shukel from front to back. During Shmoneh Esrei “he would shake his body from back to the front .” This proves absolutely nothing (i.e. it does not tell you what is correct or incorrect). This author is merely pointing out that if you want to copy the manner of a gadol – this is how he did it.
Mishnah Berurah 48:5, states that one is not permitted to stand with his body straight and only move his head; this is considered a haughty type of shukeling. “Some sway with an inappropriate type of swaying (tinuah mishubeshes). In this situation, the body stands on its axis and the individual only moves the head – sometimes to the right, sometimes to the left, in a haughty manner. It is not fitting for one to do this.”
Both Peirush Azulai ibid. and Magen Avraham 48:4, state that if one wants to shukel, he should keep it to a minimum, doing so only toward the end of the Brachos. Peirush Azulai, “However, if one is accustomed to sway when mentioning the name of Hashem – based on the verse of kol atzmosai, during Shemone Esrei he should keep the swaying to a minimum. Magen Avraham, “Some p’rushim (lit. those who abstain) are accustomed to sway gently (b’nachas) at the blessing’s conclusion… ”
It would seem obvious to this author that since one should not do anything in general that will make one conspicuous, so to in a schul were people don’t do animated shukeling, it would not be proper to do anything that would make one stick out or disturb others. Perhaps the rule of al tifrosh min’hatzibur would apply here.
What is the practical law?
Rabbi Dr. Joseph Breuer zt”l, in an essay entitled “Our Way,” (A Unique Perspective, pg. 384) points out that it was a hallmark of German Jewry – and others – that they did not shukel during teffilah. “The same holds true for our posture during the Teffilah. The Halacha is silent on the preference of a stationary versus a moving position in regard to the intensity of kavonoh during the Teffilah. The sainted Ari Ha-kadosh, and with him many of our Torah Greats, assumed stationary positions during the Teffilah – and they were certainly not German Jews.”
One must wonder as to how it is possible that so many of the mentioned sources are of German origin – yet German Jewry is known not to sway during teffilah. This question was posed to Rabbi Binyomin Shlomo Hamburger שליט”א  who responded with the following. “In Ashkenaz the custom throughout all the generations was to shukel, both during teffilah and while learning, with the exception of some individuals that stopped shukeling during teffilah due to Kabbalistic influence. Recently, most [German Jews] stopped shukeling because to them, it did not fit in with the new modern spirit of Germany.” 
Therefore, if one would like to follow the common German custom in recent years, he would not shukel. If one is intent on restoring the ancient German custom, he would shukel.
Normative Halacha says as follows: Aruch Hashulchan ibid, and Mishnah Berurah 48:5, come to the same conclusion – one may do whatever is desired. Whatever allows one to concentrate better is the proper thing to do.
Aruch Hashulchan, “During Shemoneh Esrei, some sway and some do not. This is contingent on one’s nature. If one finds that they will concentrate better while shukeling then it is proper for that person to shukel. There are those individuals that will have a clearer ability to concentrate while standing completely still – they should not shukel. It is all proper as long as it is done for the Sake of Heaven.”
Mishnah Berurah, “There are those poskim that argue and say that during teffilah one should not shukel. [They are of the opinion that it is permitted all other times] during pesukei d’zimra, the blessings on Shema, and during Torah Learning,  even of the Oral Law, the custom is to shukel. Magen Avraham writes that one may choose either method. It is all according to the individual – if one concentrates better by shukeling, let him shukel, and if not, let him stand [still] – as long as his heart is able to concentrate.
1. It should be noted that the material available on this topic is vast and not all sources are being quoted. Other sources include, but are not limited to, Rikanti, Zohar, Tziror Hamor, Rabainu Yona, and others.
2. It would appear that Abudraham is not speaking in regard to teffilah but rather just in regard to listening to the Torah reading. See the end of Darchei Moshe where he gives sources for teffilah.
3. Translation based on: http://en.wikisource.org/wiki/Kitab_al_Khazari/Part_Two. This author has partially modified it.
4. Kuzari does not indicate any distinction if this applies to learning or teffilah. The language is kre’as ha-ivris which literally means ‘the reading of Hebrew’.
5. It is important to point out that many sources that say not to shukel during Shmone Esrei are Kabbalistic.
6. This author was unable to find the entire source; therefore the parable has been left out. It should be noted that Nesiv Binah quotes Ba’al Shem Tov as saying what Rivash says.
7. Additional source for shukeling while learning.
8. It would appear from the notes on Maharil (Machon Yerushalayim edition), that some alternative readings understand that Maharil would only shukel during Shmone Esrei and at no other time. If this is indeed the case, it would appear that Maharil is the exception to the rule.
9. Apparently this means to sway gently as apposed to stooping over as one must stand straight when reciting the blessings in Shmone Esrei. See Tosefos 31a, Umotza B’zavis Acheres.
10. February 7, 2010
11. באשכנז נהגו בכל הדורות להתנענע בתפילה ובלימוד, חוץ מיחידים שהפסיקו להתנענע בזמן התפילה בהשפעת מקובלים.
בעת החדשה, הפסיקו רובם להתנענע, משום שלא לא התאים לרוח המודרנית של גרמניה.
12. Additional source for shukeling while learning.