KATHMANDU, Nepal — A Nepali court on Monday sentenced a lauded Canadian humanitarian to nine years in prison for raping two young boys last year, a case that bared a troubling trend of predatory behavior by aid workers in Nepal.

The humanitarian, Peter Dalglish, who worked for decades as an advocate for children in impoverished corners of the world, was convicted in June of sexually assaulting two boys — ages 12 and 14 — last year in Kartike, a small Nepali village of rutted roads where he built a home.

It is unclear if Mr. Dalglish, 62, who has been in Nepal’s custody for over a year and has maintained his innocence, plans to appeal the sentence, which was delivered in a district court and included a small cash payment to each of the victims’ families. Rahul Chapagain, a lawyer for Mr. Dalglish, declined to comment. Two other lawyers who also represented him could not be reached for comment.

International activists following Mr. Dalglish’s case said the ruling was just one step in addressing grave accusations of sexual abuse against children in Nepal, where thousands of nongovernmental organizations operate with limited oversight.