Their arrests in September were part of a series of highly publicised raids targeting suspected homosexuals in the conservative country.
A lower court convicted them in November of broadcasting images that "violated public decency".
The men were detained after a video, filmed aboard a Nile riverboat, showed what prosecutors said was a gay wedding ceremony, with two men kissing, exchanging rings and cutting a cake with their picture on it.
The video received widespread attention on websites such as Facebook, Twitter and YouTube.
The defendants' families, who were expecting their acquittal, screamed and wept on hearing the new sentences, according to an AFP reporter.
"They took away my heart," said the mother of one of the defendants as she slapped her face after the verdict.
Another woman whose brother was among the defendants screamed that his "future is finished".
Signup to our newsletter and follow us on Facebook and Twitter!
Defence lawyer Emad Sobhi told AFP that the ruling was "full of loopholes" and would be appealed.
Homosexuality is not specifically banned under Egyptian law and the men were initially accused of debauchery.
That charge was dropped after an invasive anal exam of the men showed that they did not have receptive anal sex.
The defence repeatedly denied that the men were gay, and insisted that the lower court had caved in to popular pressure.
One of the defendants told a television talk show prior to their arrest that the video was recorded during a birthday party.
In the past, Egyptian homosexuals have been jailed on charges ranging from "scorning religion" to "sexual practises contrary to Islam," the country's dominant religion.
In April, a court sentenced four men accused of homosexuality to up to eight years in prison.
In another case, 26 men are on trial for alleged debauchery after they were arrested at a Cairo public bathhouse in a night-time raid on December 7.