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 arriving 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.
Police named the suspect as Fernando Andrés Sabag Montiel, Brazilian-born but with an Argentine mother, who has lived in Argentina since he came to the country as a child in 1993. He had previously been arrested in 2021 while carrying a 35cm knife.
Pictures of him taken from his social media posts and published on Argentine newspaper websites depicted him with tattoos associated with neo-Nazi groups.
After searching his apartment, police seized two boxes containing 100 bullets, according to investigators quoted by La Nación newspaper.
La Nación also reported that Pope Francis had telephoned Ms Fernández de Kirchner and had a “brief and cordial” conversation with her.
The Argentine-born Pope, who has received the vice-president several times at the Vatican, also sent her a telegram in which he expressed “solidarity and closeness” with her.
He added that he was praying for “social harmony and respect for democratic values” to prevail in his native country.
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.
If convicted at trial, prosecutors have asked that the ex-president face 12 years in prison and a lifetime ban from politics.
However, Ms Fernández de Kirchner is the Senate president and so enjoys parliamentary immunity. She would not be imprisoned unless her sentence was ratified by the country’s Supreme Court, or she loses her Senate seat at the next elections at the end of 2023.
Ms Fernández de Kirchner has faced numerous other corruption trials following her time as president. The verdict of this trial is expected to take some months.