Military operation in the First World War
The Russian invasion of East Prussia occurred during World War I, lasting from August to September 1914. As well as being the natural course for the Russian Empire to take upon the declaration of war on the German Empire, it was also an attempt to focus the Imperial German Army on the Eastern Front, as opposed to the Western Front. Despite having an overwhelming superiority over the Germans in numbers, the invading Imperial Russian Army spread its forces thin and was defeated in the battles of Tannenberg and the Masurian Lakes, resulting in a complete strategic collapse of the Russian invasion.
The shock of the invasion served to assist the German war effort. According to Alexander Watson "Outrage at the violation of national territory and Tsarist atrocities strengthened German solidarity, cemented conviction in the righteousness of the national cause, and acted as a terrible and lasting warning of the penalties of defeat".
German planning.
German strategy regarding Russia was defensive from 1888 onward, when the Chief of the German General Staff, Helmuth von Moltke, abandoned the concept of a decisive offensive into Russian territory and began to consider defensive options. According to German intelligence estimates, the railway network in Poland limited the Russians to three options: a purely defensive posture against Germany, an offensive down the Vistula straight towards Berlin or an invasion of East Prussia with two armies, one from the Narew and one from the Neman. French political pressure blocked the first option, while the second option was militarily unsound, leaving the third option as the most likely Russian course of action.
In 1894 Alfred von Schlieffen, then Chief of the German General Staff, war-gamed a scenario that corresponded to the Battle of Tannenberg in 1914. With the Russian Niemen army having overrun half of East Prussia, the German commander in the exercise exploited the separation between the Russian Narew and Niemen armies to mass his troops against the right flank of the Narew army and destroy the whole force. In the exercise critique Schlieffen said the Germans could easily just establish a defensive line behind the Vistula, but when the opportunity to destroy an entire Russian army was available, it should be taken.
Whereas Schlieffen's predecessor's Alfred von Waldersee's idea had been to launch a spoiling attack on the Russians as they deployed and then wait for reinforcements from the west, Schlieffen foresaw a mobile operation on interior lines using railways to mass forces against one Russian army and destroy it before it could retreat. As a result, every German general staff officer in East Prussia in 1914 knew how to respond to the Russian offensive.
Russian planning.
Grand Duke Nicholas, who had been appointed by Emperor Nicholas II as supreme commander of the Russian Army, fully supported going to war with Germany, especially after German troops occupied the town of Kalisz in Russian territory and committed atrocities there. He was an admirer of France and also understood the need for Russia to assist France's efforts on the Western Front. He told the French ambassador that Russia would invade East Prussia quickly to draw Germany's attention away from France. Grand Duke Nicholas and the high command were optimistic, planning to split Russia's forces between East Prussia in the north and Galicia in the south, securing the Polish salient if they were successful, before then pushing from central Poland towards Berlin. But the necessity of helping France also meant that the two Russian armies advancing into East Prussia did so before their mobilization was complete.
Comparison of strength.
The invasion was led by two Russian armies: the First Army, which was commanded by General Paul von Rennenkampf and consisted of 6.5 infantry divisions, 5.5 cavalry divisions, 472 guns, 254 machine guns (later 7 new reserve divisions arrived) and the Second Army under the command of General Alexander Samsonov, composed of 11 infantry divisions, 3 cavalry divisions, 724 guns, 434 machine guns. They were confronted by the German Eighth Army, commanded by General Maximilian von Prittwitz and consisting of 14.5 infantry divisions, 1 cavalry division, 774 guns, 396 machine guns. Each Russian division consisted of 16 battalions, while each German division had 12. Russian and German battalions also differed in the number of personnel and weapons.
Although outnumbering the enemy, the Russian Army had numerous problems that contributed to its defeat: Russia was not prepared for a large war at the time as it was in the midst of a rearmament programme, as was known to the Germans. Many soldiers were untrained, its transport service was largely ineffective due to a lack of railways from the Russian side of East Prussia. Moreover, the topography slowed down the movement of Russian troops and influenced its forces to be spread out over a large territory. These natural barriers and little coordination between the two Russian armies allowed the Germans to engage each army separately, like in the Battle of Tannenberg or the Battle of Stallupönen. Russian military intelligence was greatly inferior to that of the Germans due to lack of reconnaissance units. Most importantly, the Russians lacked heavy artillery guns - a problem which would plague the Russian Army for the rest of the war. The invasion was launched before full mobilzation was complete to aid the French; The Russians promised the swift invasion should France face the main German force upon French request in 1912. 
The German 8th Army also had numerous problems. Half of it consisted of newly drafted elderly reservists.
The German Empire last participated in a war in 1871, and the Russian Empire in 1905. Therefore, the German military had no combat experience, while the Russians mostly did. This was especially true of officers and senior military leadership, Generals Samsonov and Rennenkampf participated in the Russo-Japanese War.
Battle.
However, quite quickly, Russia was able to mobilize an invasion into East Prussia. Any invasion of Prussia was an important blow to German morale as well as her general strategic situation. The German deployment on the outbreak of the war left only the 10 divisions of the German Eighth Army under General Maximilian von Prittwitz in East Prussia whereas the Russians had been able to mobilize the First Army, under General Paul von Rennenkampf and the Second Army, under General Alexander Samsonov. They entered East Prussia on 7–9 August.
The Battle of Stallupönen, fought between Russian and German armies on 17 August, was the opening battle of World War I on the Eastern Front. Initially it started in favor of the Germans, but after the approach of the Russian reserves, the Germans were forced to retreat.
The Battle of Gumbinnen, started by the Germans on 20 August, was the first major offensive on the Eastern Front during the First World War. Due to the hastiness of the German attack the Russian army emerged victorious. The Germans were forced to retreat, perhaps with the intention of performing holding actions in Masuria, or even retreating to the Vistula River which would have meant abandoning the salient of East Prussia. This would have fitted in with the plans made before the start of the First World War; that these were the positions the Germans would retreat to if the Russians put up a much stronger fight than they had anticipated. Regardless of whatever preparations had been made, however, it still remained that the Germans could not let the Prussian capital Königsberg fall into Russian hands. The moral, symbolic and military value (since it was a major military hub) of the city meant to lose it was to invite disaster on the home front, in addition to the strategic ramifications. Also, it was very likely that the Russians would have used the upper hand thus gained to use their superior forces to overwhelm the static German defenses. In short, the Germans had to fight back immediately and force the Russians from East Prussia.
The Russian supply situation was abysmal. Short of food and artillery ammunition and incorrectly believing the Germans were in full retreat, Rennenkampf did not pursue, refitted for a couple days, and lost contact. Instead of sticking to the plan and advancing south-westerly to link up with Samsonov, he instead slowly moved his First Army westerly. Under pressure to advance and cut off the supposed German retreat, Samsonov's Second Army outdistanced their supplies resulting in hungry demoralized troops.
Prittwitz panicked when the Russian onslaught entered East Prussia and believed his army would be crushed between the pincers of the two Russian armies (as was the Russian plan). He announced his intention of abandoning East Prussia and move behind the Vistula. Helmuth von Moltke the Younger, Chief of the German General Staff from 1906 to 1914 replaced Prittwitz with Paul von Hindenburg (brought out of retirement) on 22 August. Hindenburg, along with his chief of staff, the formidable Ludendorff, would approach the crisis in East Prussia very differently. In contrast to Prittwitz, Hindenburg and Ludendorff decided to take the offensive and encircle Samsonov. Following the plans of Colonel Max Hoffmann, Prittwitz's deputy chief of operations, they chose to wheel eight of their divisions counter-clockwise to attack Samsonov; taking advantage of interior lines and well-practiced ability to move quickly via the rail roads. In the Battle of Tannenberg, the casualties of the Russian 2nd Army amounted to 120,219 KIA, WIA, MIA, while the German 8th Army had only 13,058 casualties. The Second Army was destroyed and Samsonov shot himself. The Germans then forced the First and Tenth Armies to retreat out of East Prussia in the Battle of the Masurian Lakes.
The invasion was a ghastly failure for the Russians, a setback which was followed by considerable German advances in the following year, including the capture of the Polish city of Warsaw. However, the crisis caused in the German High Command by the unexpected Russian advance forced the sending of 2 corps and a cavalry division from the Western Front as part of the new 9th Army in order to support the attack on the Russians. These additional forces did not arrive in time for the twin battles as Ludendorff predicted and, had they entered France as originally planned, could have been tremendously helpful to the precarious situation in the West. In the head of French military intelligence Colonel Charles Dupont's words, "their debacle was one of the elements of our victory."
Casualties and losses.
According to the regimental lists of casualties and information from reports and logs of military operations, as well as information submitted later from the remnants of the formations that were surrounded, the units that were part of the 2nd Russian Army lost 220 officers and 5,302 soldiers killed before September 1914 (these are those who was taken out of the battlefield and buried by the Russian side), 542 officers and 11,784 soldiers were wounded (evacuated to Russia or admitted to field hospitals), missing (excluding two encircled corps) - 391 officers and 29,491 soldiers. In addition, according to reports from part of the encircled formations, the casualties in the Russian 13th and 15th army corps on October 1 (by this time those who had fallen behind or escaped from the encirclement had practically ceased to return) amounted to 1,552 officers (of which, according to available information, 111 were killed, 143 wounded and 907 were missing or captured, there is no data on the rest, especially for those called up from the reserve) and 76,472 soldiers (of which 3,130 were killed, 2,412 were wounded, 44,646 were missing, there is no data on the rest, especially for those called up from the reserve). In the 15th Army Corps, for example, according to later reports, 2,978 were killed and 25,000 men were taken prisoner. In total, the damage of the 2nd Army, according to all surviving lists and reports, can be estimated at 2,451 officers and 117,768 soldiers.
Thus, together with the current figure of the corpses of Russian soldiers buried by the German side (6,789), the 2nd Army lost 13,590 killed. However, some of the dead could remain unburied. The number of wounded was probably higher, but it is rather difficult to take them into account: in a number of cases they were captured and are counted among the prisoners. In August 1914, 543 seriously wounded Russian soldiers entered the German hospitals, 8 of them died. The total number of prisoners of the 2nd Army announced by the Germans was 15 generals, 1,830 officers,