The winger nodded home in the first half to send his nation into the last-16 and leave England booking its flight back home.
Few would have given Jose Luis Pinto's side any hope of reaching the knockout round prior to the start of the Brazil showpiece. But after stunning Uruguay 3-1 in its opening Group D encounter Saturday, Costa Rica produced another fantastic performance to progress from the group phase of a World Cup for only the second time.
Friday's game was settled in the 44th minute as Ruiz's header ensured that England will be heading home early following a 2-1 loss to Uruguay on Thursday.
A below-par Italy now faces the prospect of a mouth-watering showdown with Uruguay on Tuesday to determine who will be the other qualifier from Group D.PHOTOS: Beautiful people in Brazil | Brazil protests | Soccer fanatics | Fan tattoos
Costa Rica started brightly and came close after just six minutes when defender Celso Borges headed narrowly over the crossbar from a corner.
But, despite enjoying the better of the opening exchanges, it was unable to really test goalkeeper Gianluigi Buffon, who was restored to the starting XI after missing the 2-1 win over England due to an ankle injury.
Italy, perhaps hindered by the humidity at the Arena Pernambuco in Recife, struggled to create any opportunities of real note.
However, striker Mario Balotelli should have given the Azzurri the lead on the half-hour mark when he latched onto a superb ball from Andrea Pirlo, only to lift an effort over Keylor Navas and wide of the goal.
Balotelli showed greater composure when handed another opportunity just two minutes later, but the Milan talisman's volley was kept out by a strong Navas save.
Costa Rica remained a threat, though, and forced Buffon into action for the first time as the Juventus shot stopper prevented midfielder Christian Bolanos' curler from finding the bottom corner.
And Pinto's men were aggrieved not to have been awarded a stone-wall penalty in the 43rd minute when Joel Campbell was barged over in the area by Giorgio Chiellini after the latter had given the ball away in midfield.
Justice was served a minute later, as Ruiz met Junior Diaz's magnificent left-wing cross with an excellent far-post header that cannoned off the underside of the bar and over the line.
Cesare Prandelli's response to falling behind was a positive one as he brought on striker Antonio Cassano for midfielder Thiago Motta after the interval.
Italy dictated play from the restart with Navas twice drawn into acrobatic stops, first to tip over a long-range effort from defender Matteo Darmian and then to keep out a Pirlo free kick.
But the opportunities soon dried up for Italy as it labored to try and find a way through a determined and well-organized Costa Rica defense.
And, despite the introductions of Lorenzo Insigne and Alessio Cerci, the four-time world champion could not find a way through, with Costa Rica holding on for another famous result that ends England's slim hopes.