Victory sent Costa Rica into the second round for the first time since 1990 and meant that Group D rivals England crash out. Italy still have work to do to get through. They must get at least a draw in their final match against Uruguay.

Italy coach Cesare Prandelli said it will take a far better performance for the Azzurri to make amends against Uruguay on June 24.

"It's going to be an especially challenging match. We played them last year in the Confederations Cup and after we played well for 35 minutes, they took over," said Prandelli.

"Today our approach was wrong and we were just too slow. After we conceded the goal, we just couldn't get back into it."

Ruiz struck on the stroke of half-time in Recife after Costa Rica had a strong penalty appeal turned down. Costa Rica had other chances and were a constant threat to the Italian defence.

Coach Jorge Luis Pinto and his players could not hide their joy at the final whistle, but the 61-year-old Colombian said: "We're not resting on our laurels. Our World Cup is far from over.

"It wasn't easy to come up against a team like Italy with the players and experience they have.

"We were worried about (Andrea) Pirlo, but we shut down his space and that helped to isolate (Mario) Balotelli.

"We also did well in possession, which is not easy against the Italians."

Italy were a shadow of the side that beat England 2-1 last Saturday. It was a night of misplaced passes and slap-dash defending.

Pirlo made one sublime chip over the top of the Costa Rican defence which found Balotelli in space, only for the AC Milan striker to loft his effort off target.

Balotelli, who scored the winner against England last Saturday, pounced on a header from Pirlo a minute later but Keylor Navas blocked the striker's fierce drive from the edge of the area.

Arsenal's Joel Campbell looked to have won a cast iron penalty in the 43rd minute. He pounced on a mistake by Giorgio Chiellini and broke into the Italian penalty area where he was barged over by the Juventus defender.

Chilean referee Enrique Osses waved away furious appeals by the Costa Ricans. Pinto erupted on the touchline.

Two minutes later, Pinto was jumping for joy as Ruiz got the goal Costa Rica deserved.

Gianluigi Buffon, who sat out the England win due to an ankle knock, failed to come for a Junior Diaz cross to the far post and Ruiz produced a superb header which beat the 2006 World Cup winning goalkeeper.

Prandelli shook up his side, introducing forward Antonio Cassano for Thiago Motta in the second-half. Italy's game did not improve though.

Marcos Urena replaced Campbell on 74 minutes and his fresh legs kept Italy on the defensive.

Urena ran on to one a long ball lofted from midfield, only for Chiellini to block the striker's shot on the edge of the area.

Italy's last chance was a drive from Cerci that smacked off the face of Giancarlo Gonzalez, but his effort was offside.

Costa Rica lead Group D with six points, while Italy and Uruguay have three each. Costa Rica play England and Italy meet Uruguay on Tuesday.