Argentina had failed to muster much by way of chances but just two minutes before the penalty shoot-out, Lionel Messi picked out Di Maria for his priceless strike.
Switzerland nearly grabbed an equaliser at the death when Blerim Dzemaili`s header cannoned off the foot of the post and he sent the rebound wide of the goal.
The final result was greeted with an ecstatic roar by the Argentine-dominated crowd as the Albiceleste headed for a last-eight clash with Belgium or USA, who play later.
Although cruel for the Swiss, it provided a memorable swansong for their celebrated coach Ottmar Hitzfeld, who is quitting football and learned of his brother`s death not long before the match.
The game started cagily but the closely guarded Messi carved Argentina`s first opening when he glided into the box and crossed behind the defence.
Messi`s glorious flick of the boot left two defenders standing on the right wing but there were nothing more than half-chances in the first 20 minutes.
It was Switzerland who nearly scored when Shaqiri wriggled into the box and found Granit Xhaka, whose solid shot was blocked on the line by goalkeeper Sergio Romero.
Switzerland had an even better chance when Josip Drmic found himself one-on-one with Sergio Romero. But his attempted chip was painfully gentle and lobbed gently into Romero`s hands.
Soon after the break, Drmic let another golden chance slip when Shaqiri picked him out in the box, but this time he fired well off-target.
Argentina, getting little change through the middle, switched to pumping in crosses and it nearly paid off when Higuain`s header was tipped over the bar.
Higuain failed to connect properly with another cross from the right, before Messi struck one from distance which flew narrowly over the top.
Argentina had their best chance when Messi`s cross found Rodrigo Palacio, who had just come on for Lavezzi but he could only glance his header wide.
With extra-time looming and the crowd growing tense, Messi went at the defence with a short, jinking run and shot which was smothered by Swiss `keeper Diego Benaglio.
Tempers flared and referee Jonas Eriksson intervened when Messi tangled with Valon Behrami, and appeared to shove him to the ground. But the Argentine captain escaped without a caution.
Despite being under pressure, the Swiss had a chance for a last-minute winner. But from a deep free-kick, defender Fabian Schaer couldn`t keep his header on target.
Extra-time arrived and with it more tension as the 63,000 fans nervously watched an increasingly timid Argentina, while Switzerland became more and more bold.
Shouts of “Ole, ole!” rang out with each Swiss pass and Shaqiri railed at referee Eriksson when he inadvertently got in the way and prodded a short pass of his own.
Argentina regrouped for the second period of extra-time and Di Maria nearly broke the deadlock when his rasping shot was palmed away from the top corner by Benaglio.
Switzerland looked to be holding out for penalties — a dangerous game as, although Behrami was shackling Messi, Di Maria saw another shot deflected wide.
And their defence finally crumbled when Palacio won the ball in midfield and fed Messi, who ran forward and found Di Maria who this time made no mistake with his left foot.