YouTube
The judge ruled that they would also be subject to police supervision following the completion of their prison sentence.
In the clip, which was posted on YouTube, two men are shown exchanging rings on what seems to be a Nile riverboat while onlookers cheer.
The sentence was met with uproar from the families of the defendants, who demonstrated outside the courthouse in downtown Cairo and were cleared by police. The defendants, who had denied the charges, stood silent in the court room cage as the verdict was read, one of them holding up a copy of the Koran.
Gay marriage is not legal in Egypt, a conservative Muslim society where the footage, which went viral on social media sites in August, caused a stir online.
The sentence can be appealed.
Though homosexuality is not specifically outlawed in Egypt, discrimination is rife. Arrests of gay men occasionally make headlines and the accused are typically charged with debauchery, immorality or blasphemy, drawing criticism from rights groups.
The men were first charged in September when a public prosecutor's statement said that described the video as a "satanic ceremony" that was "humiliating, regrettable and would anger God." According to Human Rights Watch, the men were subjected to "forensic anal exminations" after their arrests.
"Over the years, Egyptian authorities have repeatedly arrested, tortured, and detained men suspected of consensual homosexual conduct," Graeme Reid, director of the lesbian, gay, bisexual, and transgender (LGBT) rights program at Human Rights Watch, said at the time. "These arrests represent another assault on fundamental human rights and reflect the Egyptian government's growing disdain for the rule of law."
Four men were arrested on similar charges in April. The largest crackdown on homosexuals in Egypt took place in 2001, when police raided a floating disco called the Queen Boat. Fifty-two men were tried in the case that drew widespread criticism from human rights groups and Western governments.
Watch the video of the alleged wedding below.
(Reporting by Lin Noueihed)