First-half strikes from forward Eduardo Vargas and midfielder Charles Aranguiz gave Chile a well-deserved victory at the Maracana, condemning Spain to a humiliating early exit.
Chile will now face the Netherlands in Sao Paulo on Monday to determine who will top Group B and potentially avoid a second-round clash with hosts Brazil.
Sampaoli's men were dominant from start to finish against a Spain team that has won each of the last three major tournaments in which they have competed.
And the 54-year-old was quick to praise the tenacity of his team.
"We're happy to have played like that versus Spain," Sampaoli said.
"We played at high speed and with bravery. I congratulate my team for a huge effort.
"We beat a very difficult opponent. I feel very proud of my players. I'll never forget today's match.
"Our strikers pressed high to stop Spain playing through the midfield. It made life very difficult for them.
"We played in a very courageous way."
Get the best features, fun and footballing frolics straight to your inbox every week.
Thank you for signing up to Four Four Two. You will receive a verification email shortly.
There was a problem. Please refresh the page and try again.