August 1914. The German Army in the east had one goal under the Schlieffen Plan: Hold Russia off until the western armies could capture Paris and knock France out of the war. Then, the victorious German armies could shift quickly to the east and defeat Russia.
To that end, Prittwitz's German 8th Army positioned itself in East Prussia and prepared to meet the advancing Russian forces. Prittwitz attempted to defeat the approaching Russian 1st Army (under Rennenkampf) before the 2nd Army (under Samsonov) could arrive. The subsequent battle of Gumbinnen was a stinging defeat for the Germans but did manage to halt the overly cautious Rennenkampf. Samsonov's 2nd Army took up a position to the south of the German 8th Army and prepared for battle.
At that point Prittwitz lost his nerve.
He requested permission from German Supreme Army Headqquarters (OHL) to retreat and abandon East Prussia to the Russians. OHL responded by sacking Prittwitz and replacing him with Paul von Hindenburg (along with Erich Ludendorff as his chief-of-staff). Hindenburg and Ludendorff were a formidable team.
Upon arriving at 8th Army headquarters, Hindenburg and Ludendorff found that an attack against Samsonov's 2nd Army was already planned and, seeing the good sense in the plan, allowed it to go forward. The northern corps of 8th Army would be pulled away from Rennenkampf's front while the southern corps would begin a feigned withdrawl to lure Samsonov into a trap. Almost all of 8th Army would then pounce on Samsonov, obliterate him, then turn on Rennenkampf and defeat him as well.
The plan worked to perfection.
Samsonov's 2nd Army, separated from 1st Army by the Masurian Lakes, was lured as far forward as the village of Tannenberg. The left and right wings of 8th Army were then let loose. The double envelopment that followed resulted in the utter destruction of 2nd Army.
8th Army then turned on the slowly advancing Rennenkampf. The 1st Battle of the Masurian Lakes ended in a complete rout as Rennenkampf's forces, demoralized by the destruction of 2nd Army, retreated back to Kovno in Russia to lick their wounds.
8th Army was totally unprepared for the decisiveness of their victory and had made no plans to continue the campaign. The men were exhausted, supplies were low, and invading Russia was not part of OHL's plan. Also, Russian victories against Austria-Hungary in Galicia made it clear that German forces would soon have to be sent to the aid of her ally if Austria-Hungary was to be saved.