Bartosz Bosacki notched his first goals for Poland to help his side to victory in Group A's dead rubber and ease the pressure on coach Pawel Janas.
Bartosz Bosacki (left) proved Poland's match winner
With both sides already eliminated from the competition, it was an uninspiring start before Costa Rica's Ronald Gomez fired a low free-kick past Artur Boruc.
However, Bosacki equalised minutes later, volleying home from a corner.
And the defender sealed the win with a thumping header, before Paulo Wanchope saw a late effort denied for offside.
The win ensured Poland, who were favourites to progress to the second round alongside Germany before the tournament, ended their campaign with a valuable win that might help keep Janas in a job following a raft of criticism.
A languid start was memorable only for referee Shamsul Maidin's booking count, a tally that had reached 10 by the end of the match.
However, after 24 minutes the match sprung to life when the Poles fell behind to Gomez's low free-kick, allowed to squirm through his own legs by keeper Boruc.
Suddenly, both sides offered more purpose and the match developed into an open contest.
Ireneusz Jelen's fine break down the right flank caused Costa Rica problems before it was eventually cleared, while Wanchope should have done better when he failed to generate any power from Gomez's square-ball into the box.
But it was left to Bosacki to net the game's second, and Poland's equaliser, when he volleyed in Maciej Zurawski's corner for his first international goal on his 13th appearance.
Bosacki ensured the victory with his second-half header
Just like the opener, the goal owed much to a keeping error, this time Jose Porras failing to collect the cross amid muted cries for a foul by Ebi Smolarek.
A see-saw end to the half saw Zurawski force another good block after a fine break, before Gomez launched a free-kick towards goal that was only denied by Jacek Bak's headed clearance.
With the sweltering 28C temperature taking its toll, the second half failed to produce much early urgency, though Costa Rica twice went close before the hour through Cristian Bolanos' looped effort and Wanchope's tame header.
But, just as it did in the second half, proceedings livened up midway through the half and, after Jacek Krzynowek had forced a fine save from long range, Bosacki notched his second of the game with a towering header at the back post from the resulting corner.
Costa Rica fought admirably thereafter, and even thought they had grabbed a late equaliser when Wanchope, hoping to mark his World Cup swansong with a goal, poked home.
However, the effort was rightly ruled out for offside and the match petered out to draw a line under proceedings of what was an ultimately pointless encounter in Hanover.
Costa Rica: Porras, Drummond (Wallace 70), Gonzalez, Umana, Marin, Bolanos (Saborio 78), Solis, Centeno, Badilla, Wanchope, Gomez (Hernandez 82).
Subs Not Used: Mesen, Fonseca, Bernard, Azofeifa, Sequeira, Nunez, Rodriguez, Alfaro, Martinez.
Booked: Umana, Marin, Gomez, Badilla, Gonzalez.
Goals: Gomez 24.
Poland: Boruc, Baszczynski, Bak, Bosacki, Zewlakow, Krzynowek, Szymkowiak, Smolarek (Rasiak 85), Radomski (Lewandowski 64), Jelen, Zurawski (Brozek 45).
Subs Not Used: Jop, Gancarczyk, Kosowski, Kuszczak, Mila, Dudka, Giza, Fabianski.
Booked: Radomski, Bak, Zewlakow, Baszczynski, Boruc.
Goals: Bosacki 33, 66.
Ref: Shamsul Maidin (Singapore).
Fifa man of the match: Bartosz Bosacki
Poland's win was only their second in the last eight World Cup matches - the other victory being a 3-1 triumph over the United States in 2002. Jacek Bak made his 75th appearance for Poland and became the nations sixth most capped player. Grzegorz Lato is record holder for Poland with 100 caps.
Costa Rica have failed to win their last five World Cup matches, losing the last four. Their most recent victory came in their opening match of the 2002 tournament against China (2-0). The all-time record of nine consecutive defeats was set by Mexico between 1930 and 1958.
Referee Shamsul Maidin from Singapore showed ten yellow cards in this match. More cards have been shown in only three World Cup matches.
Trivia stats source: Infostrada Sports