In the ruling, Judge Michael Hartmann said that the laws are a ''grave and arbitrary interference with the right of gay men to self-autonomy in the most intimate aspects of their private lives."
The laws prohibited ''gross indecency" or sexual intimacy between men if one or both are under 21. But heterosexual and lesbian couples who are 16 or older can legally have such relations.
Under the laws, gay men who engage in consensual sodomy when either is under 21 face life imprisonment.
''It is a landmark case and a long overdue judgment," said Roddy Shaw, a gay activist. ''It's the first time that sexual orientation has been upheld as a protected ground against discrimination in a Hong Kong court."
Shaw said police arrested 65 men under gay sex laws in the last five years, and 26 were convicted.
The laws have been on the books for 14 years, well before the former British colony returned to Chinese rule in 1997.
Some Christian groups condemned yesterday's decision.
Homosexuals are treated differently throughout Asia. Countries such as the Philippines and Thailand tend to be more tolerant, while ethnic Chinese cultures like Hong Kong are less open.
Hong Kong's government, which said yesterday that it was reviewing the decision, can still appeal the ruling.