Answer by taking a quote from the following article:

Hamid Karzai , (Pashto/Dari: Hmd khrzy, born 24 December 1957) is an Afghan politician who was the leader of Afghanistan from 22 December 2001 to 29 September 2014, originally as an interim leader and then as President for almost ten years, from 7 December 2004 to 2014. He comes from a politically active family; Karzai's father, uncle and grandfather were all active in Afghan politics and government. Karzai and his father before him, Abdul Ahad Karzai, were each head of the Popalzai tribe of the Durrani tribal confederation.

After winning a democratic mandate in the 2004 election, it was thought that Karzai would pursue a more aggressively reformist path in 2005. However, Karzai has proved to be more cautious than was expected. After his new administration took over in 2004, the economy of Afghanistan began growing rapidly for the first time in many years. Government revenue began increasing every year, although it is still heavily dependent on foreign aid.  During the first term in Karzai's Presidency, public discontent grew about corruption and the civilian casualties in the 2001-14. In May 2006, an anti-American and anti-Karzai riot took place in Kabul which left at least seven people dead and 40 injured. In May 2007, after as many as 51 Afghan civilians were killed in a bombing, Karzai asserted that his government "can no longer accept" casualties caused by U.S. and NATO operations.  In September 2006, Karzai told the United Nations General Assembly that Afghanistan has become the "worst victim" of terrorism. Karzai said terrorism is rebounding in his country, with militants infiltrating the borders to wage attacks on civilians. He stated, "This does not have its seeds alone in Afghanistan. Military action in the country will, therefore, not deliver the shared goal of eliminating terrorism." He demanded assistance from the international community to destroy terrorist sanctuaries inside and outside Afghanistan. "You have to look beyond Afghanistan to the sources of terrorism," he told the UN General Assembly, and "destroy terrorist sanctuaries beyond" the country, dismantle the elaborate networks in the region that recruit, indoctrinate, train, finance, arm, and deploy terrorists. These activities are also robbing thousands of Afghan children of their right to education, and prevent health workers from doing their jobs in Afghanistan. In addition, he promised to eliminate opium-poppy cultivation in his country, which is possibly helping fuel the ongoing Taliban insurgency. He has repeatedly demanded that NATO forces take more care to avoid civilian casualties when conducting military operations in residential areas. In a September 2006 video broadcast, Karzai stated that if the money wasted on the Iraq War had been actually spent on rebuilding Afghanistan, his country would "be in heaven in less than one year".

How did he deal with the discontent?
Karzai asserted that his government "can no longer accept" casualties caused by U.S. and NATO operations.