Other valiant souls include his closest friend, Naome, a lesbian activist, and Bishop Christopher Senyonjo, who has been expelled from the Anglican Church of Uganda for his defense of gay rights. The film’s most upsetting scene is a clash between antigay and gay activists at Mr. Kato’s funeral.

The villains include David Bahati, a member of Parliament who in 2009 introduced legislation proposing the death penalty for a “serial offender” of the “offense of homosexuality,” and Giles Muhame, the managing editor of Rolling Stone, a popular tabloid unconnected with the American magazine of the same name. Under the headline “Hang Them,” it published the pictures, names and addresses of 100 men and women thought to be gay.

There are a few rays of light in the film. Mr. Kato, for all his seriousness as an activist, is playful and upbeat, and in scenes in which he and his friends are together in safe places, their high spirits are unquenchable. The documentary also notes a victory that was won three weeks before his death, in Uganda’s High Court, which ruled that Rolling Stone had threatened the “fundamental rights and freedoms” of gay people and violated their constitutional right to privacy. Because of international pressure, Uganda’s president, Yoweri Museveni, has warned that passage of the Anti-Homosexuality Bill could isolate the country. To those pursuing antigay legislation, he has urged caution and moderation.