It was only by chance that the victim did not suffer serious and potentially lethal injuries, the presiding judge at the Oldenburg district court said while passing sentence on the two male and female defendants, both aged 17.
The girl was treated in hospital after the assault in the coastal town of Wilhelmshaven.
Prosecutors who brought charges of attempted manslaughter against the ring leaders are investigating the extent of involvement of nine other teenagers present at the time.
Some of the group used their mobile phones to record the attack in which the girl was repeatedly and forcefully punched in the face and kicked on the ground. One of the attackers also stole her phone.
The defendants, who both previously committed offences, were temporarily released from custody until their youth incarceration sentences are due to take effect.
Film of the attack in Wilhelmshaven was later posted on the internet. Police then had to intervene to break up a group of 40 teenagers who had agreed via social forums to 'visit' the male attacker at his home.
Monday's sentences came less than three weeks after a video clip on the internet showed a similar attack by a group of teenage girls on a 13-year-old in a playground in Tübingen, Baden-Württemberg.
The clip drew immediate and fierce public condemnation. Police appealed to media not to show the entire footage to avoid provoking vigilante retribution.