Kreshnik Berisha, 20, born near the business capital Frankfurt to a family from Kosovo, was found guilty of membership in a foreign terrorist organisation, said presiding judge Thomas Lagebier.
In 2013, Berisha travelled to Syria via Turkey to support Isis in its armed struggle against the regime of Bashar al-Assad.
"I saw it as my duty to go to Syria to oppose oppression and tyranny," the bearded man said in a statement read out by his lawyer.
Berisha was tried under juvenile law, which German courts can apply to defendants aged 18 to 21.
During the trial, the man confessed to taking up arms for the Islamic fundamentalist terror group, though he denies that he shot at any people.
He was arrested at Frankfurt airport nearly a year ago upon his return.
Federal prosecutors, the defense and the state security division had agreed on a prison term ranging between three years and three months to four years and three months.
The original charge of planning a crime endangering the state from abroad was dropped.
Germany's intelligence service believes there are about 550 German nationals who have joined Isis in Syria and Iraq. Of those, 60 have died in suicide attacks or combat and a further 180 have returned to Germany.