Footage shows the moment Cristina Fernández de Kirchner – surrounded by a mob of supporters – found herself face-to-face with the loaded weapon.
The former president was returning home from court, where she faces allegations of corruption. She denies the charges.
Police said the gunman, who local media identified as a 35-year-old Brazilian man, has been taken into custody.
They are attempting to establish a motive for the attack on the left-leaning politician, who was Argentina’s president from 2007 to 2015, and its first lady for four years before that.
President Alberto Fernández revealed the gun was loaded with five bullets, but failed to fire when triggered.
Video circulating on social media shows the gun emerging from the crowd as Ms Fernández de Kirchner approaches. She initially appears confused by what is going on, ducking down to retrieve an object dropped on the floor.
In another video, people in the crowd appear to try to block Ms Fernández de Kirchner from the suspected gunman, who came within inches of her. The crowd has been gathering outside her home for the last few nights in a show of support as she fights charges of defrauding the state and being involved in a scheme to divert public funds while she was president.
A police spokesperson earlier told Reuters news agency that a weapon was found a few metres from the scene after the man had been arrested.
Addressing the nation late on Thursday night, President Fernández – who worked as chief-of-staff to both Ms Fernández de Kirchner and her husband during their tenures – said: “Cristina remains alive because, for a reason not yet technically confirmed, the gun, which contained five bullets, did not fire.”
He went on to condemn the attacker and said the attempt on Ms Fernández de Kirchner’s life was one of the “most serious” incidents since the country returned to democracy in 1983.
“We can disagree, we can have deep disagreements, but hate speech cannot take place because it breeds violence and there is no chance of violence coexisting with democracy,” President Fernández said, declaring a national holiday on Friday to allow Argentines time to “express themselves in defence of life, democracy and in solidarity with our vice president”.
Argentina’s economy minister, Sergio Massa, called the attempted shooting an “attempted assassination”.
“When hate and violence prevail over debate, societies are destroyed and situations like these arise: attempted assassination,” he said in a tweet.
Ms Fernández de Kirchner has yet to make any comment.
She is accused of defrauding the state and of fraudulently awarding public works contracts in her stronghold in Patagonia while she was president between 2007 and 2015.