Third secretary Mohammad Zaki died of his injuries shortly after the attack, a spokesman for the consulate said.
The private security officer, who is an Afghan, is in custody. Police say he was the diplomat's personal bodyguard.
Officials say he opened fire following a dispute between the two men. What prompted the argument remains unclear.
"We were working at our office when we heard gunshots," consulate spokesman Haris Khan said, Associated Press reports. "Everybody was running in panic when I got out."
Afghanistan's ambassador to Pakistan Omar Zakhilwal confirmed the shooting.
"It seems to be a personal dispute related criminal act," he wrote on his official Facebook account.
Police and paramilitary forces were deployed to the Clifton district area around the consulate after the shooting broke out.
Karachi, Pakistan's largest city and commercial capital, has a history of political, sectarian and militant violence - and there have been a number of attacks on foreign missions based there.
An Afghan diplomat has been shot dead by a security guard at the country's consulate in the southern Pakistani city of Karachi.