Miroslav Klose's double and brilliant strikes from Philip Lahm and Torsten Frings lit up the World Cup's opening match as hosts Germany won in style.
Klose's two goals helped Germany on their way to victory
Lahm's stunning sixth-minute drive from distance put Germany ahead, but Paulo Wanchope slid home to level.
Klose converted Bernt Schneider's cross, then followed up his own header to put the home team 3-1 ahead.
Wanchope produced a smart finish to give Costa Rica hope, but Frings' sensational 30-yarder sealed victory.
It was the perfect start for Germany coach Jurgen Klinsmann, whose side triumphed in the highest-scoring opening match in World Cup history.
But he will know the hosts face tougher challenges ahead, as Costa Rica offered his side huge, inviting gaps in defence.
The Costa Ricans were quick to demonstrate how generous they were to be at the back - Danny Fonseca's slip giving Lahm space to cut inside on the edge of the box.
Nevertheless, no goalkeeper in the world would have saved the full-back's unstoppable curling shot which flew into the top corner of Jose Porras' net.
Philip Lahm's stunning early strike started the party in Munich
The Germans were threatening a rout - Lahm's strike was bracketed by efforts from Frings and Bernt Schneider which both flew just over.
Yet their lead proved short-lived as former Derby County and Manchester City marksman Wanchope timed his run to perfection before sliding the ball under Jens Lehmann on 12 minutes.
But Munich's party mood was only interrupted for five minutes.
Klose, celebrating his 28th birthday, produced an accomplished finish, converting Schneider's low cross.
The Germans' long-range shooting had left Porras looking decidedly nervous and he was thankful to see the ball cleared after he fumbled a long-range effort from Bastian Schweinsteiger.
The Costa Ricans could have stunned the Germans again at the start of the second half had Fonseca been able to head home when he was left unmarked in the box.
For all their possession, Germany occasionally looked uncertain in defence, but Costa Rica did not appear to have the pace to trouble them.
And they were made to pay on 61 minutes when Klose followed up to shoot home after his own header had been parried by Porras.
Yet Wanchope soon joined Klose by netting his second in classy fashion to seemingly set up a nervy finish.
The striker produced a cool finish past Lehmann after Walter Centeno's crisp through-ball - although the Germans felt he was offside.
But still the chances came. Per Mertesacker's header from a corner produced a fine reflex save from Porras.
And Frings had the final say with an unstoppable effort which may have even bettered Lahm's as it curled away from the Costa Rica keeper into the corner to leave the home fans in party mood.
Germany: Lehmann, Friedrich, Mertesacker, Metzelder, Lahm, Schweinsteiger, Frings, Borowski (Kehl 72), Schneider (Odonkor 90), Podolski, Klose (Neuville 79).
Subs Not Used: Asamoah, Ballack, Hildebrand, Hitzlsperger, Huth, Jansen, Kahn, Nowotny.
Goals: Lahm 6, Klose 17, 61, Frings 87.
Costa Rica: Porras, Marin, Umana, Gonzalez, Martinez (Drummond 67), Fonseca, Solis (Bolanos 78), Centeno, Sequeira, Gomez (Azofeifa 90), Wanchope.
Subs Not Used: Alfaro, Badilla, Bernard, Hernandez, Mesen, Nunez, Rodriguez, Saborio, Wallace.
Goals: Wanchope 12, 73.
Ref: Horacio Marcelo Elizondo (Argentina).
Fifa man of the match: Miroslav Klose.
The 4-2 result marked the most productive opening match in World Cup history. Germany continued a tradition of undefeated host nations in their first match in a World Cup finals. The Germans have now triumphed in their initial match in each of the last five World Cups.
Philipp Lahm joined countrymen Josef Gauschel (1938), Paul Breitner (1974) and Jurgen Klinsmann (1994) as Germans who have scored the opening goal in a World Cup edition.
Paulo Wanchope became the first Costa Rican player to have netted in more than one World Cup edition and joined Ronald Gomez as the only Costa Rican players to have scored more than one World Cup goal.