KABUL, Afghanistan — A former Afghan official has accused President Ashraf Ghani’s administration of engaging in widespread corruption, including the exchange of sexual favors for government posts, adding to a string of recent setbacks for the government.

The accusations, leveled by Gen. Habibullah Ahmadzai, a former senior adviser to the president, during a TV interview last week, come as Taliban insurgents ramp up attacks across the country and as the United States tries to negotiate a peace deal with the militant group.

The corruption claims exploded on social media after they were backed up on Saturday night by Mariam Wardak, a former consultant to Mr. Ghani’s former national security adviser. During an interview with an Indian news channel, World Is One News, Ms. Wardak echoed General Ahmadzai’s accusations, saying, “The issues he brought up and highlighted reflect reality.”

With the presidential elections just months away, the timing of the allegations, with no evidence, could be politically motivated. And they could also ensure serious ramifications for women working in the Afghan government, since even moderate urban men are often hesitant to allow the women in their families to work in public offices.