Porto winger Diaz, who had put Colombia 2-1 ahead midway through the second half, settled a thrilling contest in the 94th minute with an exceptional long-range effort.
It came 12 minutes on from Gianluca Lapadula's equaliser, after Juan Cuadrado had cancelled out Yoshimar Yotun's opener, with the match seemingly destined for penalties – Colombia having gone the distance in both previous knockout rounds.
Yet Diaz ensured third place was theirs without the need for such drama, capping off an impressive campaign for Reinaldo Rueda's side, who also gained revenge for a group-stage defeat.
Peru should have gone ahead in the 28th minute – Lapadula drilling wide when one-on-one with Camilo Vargas.
But Diaz had the final say, the 24-year-old driving in from the left and engineering space for a shot 25 yards from goal, sending a wonderful finish into the top corner to seal victory.