Cristina Fernandez de Kirchner was greeting supporters outside her home when a man emerged from the crowd and pointed a handgun in her face.
President Alberto Fernandez said the gun was loaded with five bullets but failed to fire when triggered.
Ms Fernández de Kirchner is involved in a corruption trial and was returning from court. 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.
Addressing the nation late on Thursday night, Mr Fernandez said: "Cristina remains alive because, for a reason not yet technically confirmed, the gun, which contained five bullets, did not fire."