Northern Ireland striker David Healy scored a spectacular winner against Denmark to become the record scorer in a European qualifying campaign.
Chris Sorensen of Denmark tangles with Keith Gillespie
He scored his 13th goal of the campaign with a brilliant chip 10 minutes from time at Windsor Park.
In difficult conditions, the Danes had taken the lead in the 51st minute when Nicklas Bendtner poked in.
Warren Feeney headed in an equaliser 10 minutes later to set the stage for Healy's stunning strike.
Northern Ireland will go to Spain on Wednesday still with an outside chance of making the Euro 2008 finals.
Even if they beat the Spaniards they would need Latvia to take all three points against Sweden.
Whatever happens, the victory over Denmark was the perfect reward for another fine display by Northern Ireland.
However, the match almost did not take place at all after a lengthy torrential downpour.
It was not until five minutes before the kick-off that Dutch referee Pieter Vink finally decided the match could go ahead even though there was surface water in most areas of the pitch and it was still raining heavily.
The conditions were farcical in the early stages with the ball often being held up in puddles of water.
Denmark almost took the lead on 13 minutes but Dennis Rommedahl skied his back-post effort high and wide.
David Healy then tested Thomas Sørensen but the goalkeeper pushed away his effort and then Jonny Evans headed narrowly wide following a corner.
Keith Gillespie was then booked for a challenge on Chris Sorensen and he will miss the match against Spain.
Denmark tok the lead in the 51st minute through Arsenal striker Bendtner.
He beat seveal defenders to the ball to toe-poke in after a long throw from Leon Andreasen.
But Northern Ireland found the perfect response 10 minutes later with Chris Brunt delivering from the left flank for Feeney to get in at the near post to head in the equaliser.
Feeney almost got his fourth international goal just three minutes later only to see his dipping half-volley from 35 yards strike an upright.
And Healy's record-breaking goal, when the Fulham forward chipped keeper Jesper Christiansen, saw him overtake Croatia's Davor Suker who scored 12 in the Euro 96 qualifying campaign.
In the process the Fulham forward took his overall tally to 33 goals in 61 internationals.
Denmark piled on the pressure at the end, hitting a post and then having a good penalty claim turned down for a hand ball by Sammy Clingan.
But fortune smiled on Northern Ireland and they held on for only their second-ever victory over Denmark.
Northern Ireland: Taylor, McAuley, Evans, Hughes, Craigan, Clingan, Gillespie, Davis, Brunt, Healy, Feeney.
Subs: Mannus, Baird, Sproule, Capaldi, Hamilton, Robinson, Paterson.
Denmark: Thomas Sorensen, Priske, Chris Sorensen, Martin Laursen, Kroldrup, Christian Poulsen, Andreasen, Kahlenberg, Rommedahl, Jorgensen, Bendtner.
Subs: Andersen, Niclas Jensen, Ulrik Laursen, Wurtz, Simon Poulsen, Larsen, Dennis Sorensen.
Referee: Pieter Vink (Holland)