Islam’s leaders must be more forceful in condemning jihadi violence in the Middle East and around the globe, Afghanistan President Ashraf Ghani told lawmakers in an address to a joint session of Congress Wednesday.

Mr. Ghani, a former World Bank official elected in September, repeatedly thanked the U.S. aid for its military sacrifice and economic aid since the 9/11 attacks, receiving a warm reception and several standing ovations from lawmakers that was in sharp contrast to the prickly relations seen under predecessor Hamid Karzai.

Mr. Ghani said Afghanistan’s attempts to rebuild had been complicated by the continuing threat from Taliban insurgents and by the rise of Islamist terror movements from the Middle East such as Islamic State in the wake of the Arab Spring.

Acknowledging that Islamic State representatives have already tried to export their struggle to his country, Mr. Ghani said political leaders in Islamic nations must be more forceful in denouncing terror movements claiming to represent the Muslim faith, an extremism he compared to a “dangerous virus.”

“Leaders, intellectuals and those many millions of Muslims who believe that Islam is a religion of tolerance and virtue must find their voice,” he said. “Silence is not acceptable.”

The Afghan president praised the “steadfastness” of the Obama administration in supporting Kabul despite strained times with Mr. Karzai that held up a new security agreement between Afghanistan and the U.S.-led international force that has led the battle against the Taliban.

The bilateral relationship “lost momentum” in 2014, Mr. Ghani admitted, but the two sides have “made up for lost time” since the transfer of power in September.

“Thank you for staying with us,” he said.

In a meeting at the White House Tuesday, Mr. Ghani secured a promise from President Obama that the 9,800 American troops deployed in Afghanistan will stay through the end of 2014, delaying earlier plans to cut that number in half.

But Mr. Obama has said that his promise to withdraw virtually all U.S combat troops from the country by early 2017 still stands.

Mr. Ghani argued that his poor country has made significant strides on a number of social measures, winning a lengthy standing ovation when he noted that, unlike before the 9/11 attacks, Afghan girls can now be educated in the nation’s schools.

Thanks in part to major U.S. and international aid, he said, Afghanistan also was on track to becoming economically self-sufficient within a decade.