JOHANNESBURG — Two gay men in Malawi, convicted this week of unnatural acts and gross indecency, were sentenced Thursday to the maximum penalty allowed by law, 14 years of hard labor in prison.

The harsh sentence was immediately deplored by human rights groups around the world, but Magistrate Nyakwawa Usiwa Usiwa, in reading his judgment, seemed adamant in his ruling. He said he was especially offended that the two lovers celebrated their relationship in public with an engagement party.

“I do not believe Malawi is ready at this point in time to see its sons getting married to other sons, or cohabitating, or conducting engagement ceremonies,” the magistrate said. “Malawi is not ready to smile at her daughters marrying each other. Let posterity judge this judgment.”

The couple — Tiwonge Chimbalanga, 33, and Steven Monjeza, 26 — remained still as they heard the sentence, though Mr. Monjeza was seen weeping after the two were handcuffed and led away. As with earlier court appearances, a sizable crowd was outside, mostly to ridicule the men and rejoice at the spectacle.