Karzai also told Narendra Modi that a thorough investigation has been launched into the attack.
Modi also spoke to India's Ambassador in Afghanistan Amar Sinha soon after the attack and lauded the role of security forces manning the consulate for their valiant efforts in fighting and killing the terrorists who attacked it.
"President Karzai & I talked about consulate attack in Herat. He assured me he will do everything to protect India's Missions in Afghanistan," Modi tweeted.
During their telephonic conversation, the Indian PM-designate also thanked Karzai for the efforts of the Indian and Afghanistan forces in thwarting the attack on the Indian Consulate.
"I condemn the attack on our consulate in Herat, Afghanistan. Closely monitoring the situation. I have spoken to the Ambassador as well," Modi said.
"India salutes the efforts of India's security personnel & Afghan security forces for their valiant efforts to fight the terrorists in Herat," he tweeted, adding "I salute the consulate staff for their indomitable spirit & high morale throughout the difficult circumstances."
A statement by the Afghan President's office said Karzai telephoned Modi and "strongly condemned todays terrorist attack on the Indian consulate", calling it "an attack on Afghanistan, India and our shared interests."
Karzai briefed Modi on the timely response of the Afghan security forces to repel the attack and assured him and the Indian people of the safety of their citizens in Afghanistan, it said.
Karzai said the Indian diplomatic missions in Afghanistan have, in the past too, been attacked by terrorists.
However, the President stressed, "such attacks would only embolden the two countries resolve and commitment in further strengthening their cooperation especially in fighting terrorism as a common enemy."
Modi thanked Karzai for the call and assurances of safety for Indian citizens and for the rapid response of the Afghan security forces in containing the attack, the statement said.
He reaffirmed his countrys continued friendship, commitment and engagement in reconstruction and stability in Afghanistan.
Gunmen armed with heavy weapons including rocket propelled grenades launched a pre-dawn assault on the consulate during which all the four attackers were killed. All the diplomatic staff were safe.
Indian Ambassador to Afghanistan Amar Sinha said there were nine Indians in the mission apart from local Afghans.