Costa Rica, playing in its first World Cup, qualified for the second round yesterday as Roger Flores and Hernan Medford scored five minutes apart in the second half for a 2-1 victory over Sweden in Genoa.

It was the first time in the 1990 tournament a team had come from behind to win. Costa Rica had trailed by 1-0 at the start of the second half, but Flores connected in the 75th minute and Medford in the 85th.

That sent the Central Americans on to the next round. Costa Rica, which finished just ahead of the United States in group qualifying, also beat Scotland and lost to Brazil in Group C games.

Sweden, regarded as No. 2 to Brazil in the group when the tournament began, lost all three of its games.

Johnny Ekstroem scored on a rebound off a free kick by Stefan Schwarz to give Sweden a lead for the first time in the Cup.

Costa Rica's tying goal was set up when Schwarz drew a yellow card for pulling down Medford as he broke toward the goal. Juan Cayasso then launched a perfect free kick and Flores headed it past goalie Thomas Ravelli, setting the stage for Medford.

The substitute forward caught the Swedish defense napping, breaking free just beyond midfield and beating Ravelli.

It was Medford who sparked what had been a stagnant Costa Rican offense when he came on in the 60th minute in place of Roger Gomez. Medford created three scoring chances within moments of entering the game.

Sweden's goal in the first half came despite a dazzling performance in the net by Luis Conejo. Before the goal, Conejo had stopped four solid scoring chances, twice diving to save hard shots and once blocking a line-drive header.

Conejo made another diving save in the 32nd minute, on Schwarz's free kick. But he couldn't control the rebound and Ekstroem was in perfect position to pop it in.

Brazil 1, Scotland 0: In Turin, Muller scored with nine minutes remaining to lift the Brazilians to victory and virtually assure the Scots' first-round elimination for the seventh straight time.

Scotland, which never has advanced beyond the opening round, probably would have gained the next round with a tie.

Goalie Jim Leighton had made a save on a shot by Alemao, but the rebound went to a charging Careca, who nudged the ball toward the goal and past Leighton. Muller, unguarded at the right, did the rest.

Brazil, which already had qualified for the second round from Group C, won its three first-round games for six points. Costa Rica finished second in the group with four.

Scotland ended up third with two points, not likely to be enough to advance. But the Scots must wait for Thursday's results, the last four games of the first round.