The army's rule had stipulated that military personnel could not engage in sexual relations with persons of the same sex either within or outside their barracks.
But constitutional court official Samuel Abad dubbed that rule "completely discriminatory."
Gays in the armed forces had been subject to expulsion or prison sentences if they engaged in homosexual relations, even outside their barracks, under a rule that Aldo Araujo of Lima's Homosexual Movement gay rights group declared "a violation of people's right to privacy."