Addressing revulsion at the widespread sexual abuse of boys by powerful Afghan commanders, President Ashraf Ghani pledged on Wednesday that his government would do what it could to stamp out a practice that is pervasive among many wealthy and prominent men in his country.

Mr. Ghani was unambiguous in his condemnation of the practice, calling it “unacceptable” and saying that pedophiles would be prosecuted no matter who they were.

“Six-year-, 8-year-, 10-year-olds are raped, and I’m not going to tolerate this,” Mr. Ghani said from Kabul in an interview conducted by video conference. “To the extent to which the authority of the state can be harnessed to this task, we are going to focus on it and not permit it.”

That will be no easy feat. Though many Afghans find it repugnant, the sexual abuse of boys is so widespread that the practice even has a euphemistic name — bacha bazi, literally “boy play” — and is often ritualized in parties at which young boys are dressed as girls and forced to dance before they are raped.