Villa scored from 45 meters (yards) in the 24th minute at Loftus Versfeld. He ran on to a loose ball and curled a left-footed shot into an open goal after Chile goalkeeper Claudio Bravo had rushed out of the area to clear Xabi Alonso's long ball.
Iniesta, who returned from a right leg injury, jumped on a loose ball in the midfield and eventually worked it to Villa down the left. The Barcelona striker drew defenders Arturo Vidal and Mauricio Isla before passing back to Iniesta to side-foot past Bravo in the 37th.
Marco Estrada was sent off after being booked for a second time during the buildup to the second goal. After replacing the suspended Carlos Carmona as holding midfielder, Estrada was first booked in the 21st and shown a red card for tripping Fernando Torres.
Chile substitute Rodrigo Millar pulled one back for the South American team, scoring from a deflected shot in the 47th.
Spain finished at the top of Group H with six points and will play Portugal in the next round, while Chile also has six points and will face Brazil after finishing second on goal difference.
In the other group match, Honduras held Switzerland to a 0-0 draw, eliminating both teams.
Estrada's sending off gave Spain space to work its quick-touch passing game and hold better possession after a bruising start when the Chileans were able to knock the Spanish off the ball and looked dangerous on the counterattack.
With Spain starting the second half slowly, Millar -- who replaced Mark Gonzalez to start the half -- took advantage of the time and space given to him at the edge of the area for a shot that deflected off Gerard Pique and leave goalkeeper Iker Casillas without a chance.
But Spain held on for a win that ensured one of the pre-tournament favorites advanced despite not being at its sharpest.
Spain's passing game -- its usual strength -- was far from crisp as it was slow in the buildup to goal although Torres had a valid penalty shout after being pushed to the ground by Vidal inside the area in the 36th.
Torres was replaced by Cesc Fabregas in the 55th as the Liverpool striker struggled again in his second start since undergoing right knee surgery.
Villa, who became Spain's all-time leading World Cup scorer with his sixth goal, joined Argentina striker Gonzalo Higuain and Robert Vittek of Slovakia as leading scorers in South Africa with three goals.
Chile was the first South American team to lose a match at this year's World Cup.