The National Directorate of Security (NDS) released a statement saying the agency's chief survived what it called a "cowardly terrorist attack."
Reports say Khalid was wounded while receiving a visitor in the afternoon at a guesthouse run by the Afghan intelligence service.
A senior Afghan official told the Associated Press that Khalid suffered injuries to the lower part of his body. The spy chief was rushed to a hospital run by the NDS.
"Our intelligence director who was injured in a cowardly terrorist attack is now undergoing surgery. The doctor treating him gave me the details. They are positive," Afghan President Hamid Karzai told journalists after visiting Khalid in the hospital.
"For now we have great hopes for his full recovery."
Journalists later received an e-mail, said to be from the Taliban, claiming responsibility for the attack.
In August, Khalid was nominated by Karzai to head the NDS. The Afghan parliament confirmed the appointment in September.
Accusations From Time As Governor
The 43-year-old spy chief is an ethnic Pashtun from the central Ghazni Province.
He is considered close to Afghan lawmaker Abdur Rab Rasul Sayyaf, a veteran of the fight against Soviet forces in the 1980s.
Khalid was the governor of Ghazni and Kandahar provinces between 2005 and 2008. He was later appointed to run the Border and Tribal Affairs Ministry -- a post he held until his appointment to the NDS in August.
International human rights organizations have accused him of torture, unlawful killings, and running private prisons. They objected to his appointment as NDS chief and called for an investigation into the allegations against him.
In September, Amnesty International said that there were credible allegations that Khalid was "involved in the bombing of a vehicle that killed five UN workers in Kandahar in April 2007."
Khalid is considered a close confidant of Karzai and a staunch enemy of the Taliban. He survived a suicide bombing in Kandahar in 2007.