Defending champion Spain sealed top spot in Group C by beating Croatia 1-0 with a late goal by substitute Jesus Navas. Croatia's football association faces a UEFA charge on Tuesday over its fans' racist abuse of Italy forward Mario balotelli last week.
Balotelli came off the bench to score Italy's second goal in a 2-0 victory against Ireland, lifting the Azzurri above Croatia in the standings. Antonio Cassano had opened the scoring for the Azzurri.
Earlier, UEFA President Michel platini said he was "not happy" with Croatia fans at Euro 2012.
Meanwhile, UEFA punished Denmark forward Nicklas Bendtner for revealing a sponsor's name on his underpants after scoring a goal in his team's opening game.
The victories for Spain and Italy will send them from their Poland-based group to quarterfinals in Ukraine against either the co-host, England or France.
Spain will play on Saturday in Donetsk, and Italy goes to Kiev on Sunday.
Elaborate Spanish possession play failed to create many scoring chances in Gdansk, despite the World Cup winners knowing a 1-0 loss would mean a ticket home.
Iker Casillas, the goalkeeper and captain, saved Spain with a double stop from Croatia's Ivan Rakitic in the 59th minute, then parried Ivan Perisic's low volley in the 79th.
Spain's passage was confirmed when Navas, who replaced Fernando Torres, struck in the 88th, tapping into an empty net from a pass by Andres Iniesta after the pair had broken the offside trap.
Italy knew that a 2-0 win would not be enough in Poznan if Spain and Croatia drew 1-1.
Antonio Cassano continued his impressive recovery from minor heart surgery in midseason to score with a header from a 35th-minute corner, glancing in a header at the near post that had too much pace on it for goalkeeper Shay Given to keep out.
Ireland showed attacking intent after appearing overwhelmed in previous losses, but midfielder Keith Andrews was sent off for collecting a second yellow card in the 89th.
One minute later, Balotelli scored by hooking a volleyed shot over his left shoulder.
Balotelli, a target for racist abuse in both Italy's earlier matches, appeared then to vent anger and emotion. One teammate tried to try to calm him and covered his mouth.
When the match ended, Italy's players stayed on the pitch for an anxious minute until Croatia's defeat was confirmed.
"I couldn't wait for them to blow the whistle in the other game and for it to finish," Cassano said. "The victory was something we suffered for but the most important thing was to get through the group."
For the third straight Croatia game, fans threw flares which belched smoke around the stadium, likely further upsetting Platini who attended the Italy match.
The UEFA chief earlier told reporters that the atmosphere in Euro 2012 stadiums had been "99 percent great" with "nice people, except some Croatians."
Croatia's football body will be punished on Tuesday for fans making monkey noises at Balotelli, who is black.
Croat fans throwing fireworks also delayed two matches in Poland, while others burned a European Union flag and paraded posters of a convicted war criminal in Poznan city center.
"I am not happy with the Croatian people," said Platini. He visited the country last year to warn political and football leaders about possible UEFA suspensions if hooliganism was not curbed.
Platini said he was "delighted" with co-hosts Poland and Ukraine, who "have already won the Euro" by defying doubters to organize a successful tournament.
"The people who love football thank us. The people who don't love football thank us for the legacies we are leaving for the future," he said.
After Bendtner's underwear stunt last week, UEFA's disciplinary panel banned him for one 2014 World Cup qualifying match. UEFA also fined the striker ?100,000 ($126,000) for breaking ambush marketing rules in his team's 3-2 loss against Portugal.
Bendtner said he would "appeal the decision and take it from there," in comments to Denmark's TV2 News as the team returned to Copenhagen after exiting Euro 2012 on Sunday.