The plotters, who included university students and a medical professor, had been trained to launch attacks in the capital Kabul and had recruited one of Karzai's bodyguards to kill the president, the National Directorate of Security (NDS) said.
"A dangerous and educated group including teachers and students wanted to assassinate President Hamid Karzai," spokesman Lutfullah Mashal told a news conference.
"Unfortunately they infiltrated the presidential protection system and recruited one of the president's bodyguards."
Mashal said those detained had ties with three men, including an Egyptian and a Bangladeshi, who were all members of al-Qaeda and the Haqqani network which is based in Pakistan's tribal region of North Waziristan, bordering Afghanistan.
Those arrested were part of a "most sophisticated" group who confessed to having been trained to use guns, rockets and suicide attacks, he said, with top government officials among the targets.
They also said they had received $150,000 to fund their activities, and planned to kill Karzai during one of his trips outside the capital, Mashal added.
Karzai has been the target of at least three assassination attempts since becoming Afghan leader in 2002, most notably in April 2008, when insurgents fired guns and rockets at a military parade he attended near the presidential palace in Kabul.
Mashal said the bodyguard, Mohebullah Ahmadi, was from Kazai's home village of Karz in southern Kandahar province, and he had been shown al-Qaeda and Haqqani video propaganda to persuade him to take part in the assassination plot.
The Haqqanis are one of three Taliban-allied insurgent factions fighting in Afghanistan. Perhaps the most feared, they are thought to have introduced suicide bombing to the country, and to be behind many high-profile attacks.
They have sworn allegiance to the Taliban, but have long been suspected of also having ties to Pakistan's spy agency, the Inter-Services Intelligence (ISI) directorate.
NATO-led forces fighting in Afghanistan said on Wednesday that an airstrike had killed a senior Haqqani commander and two of his associates in eastern Khost province, near the Pakistani border.
Dilawar, known by only one name, was a "principal subordinate" to Haji Mali Khan, who was captured by NATO last week and said at the time to be the top Haqqani commander for Afghanistan.
Dilawar's death is "another significant loss for the insurgent group", the NATO-led International Security Assistance Force (ISAF) said in a statement that described his responsibilities as including coordinating attacks on Afghan forces, and arranging weapons deliveries.