A fantastic volley from Jamie Tolley was enough for non-league Wrexham to knock Brentford out of the FA Cup.
The Bees weren't at the races in the first half and the Welsh side deserved their lead.
Brentford responded in the second period but could not find a way through and Wrexham booked a place in the Third Round draw.
The visitors sensed a cup shock in the early stages - Adrian Cieslewicz dribbled a shot wide and then had a shot blocked by team mate Danny Wright, with Nat Knight-Percival flagged offside as he tried to turn in the loose ball.
The Bees were a long way below par in the first period and, coupled with a fine performance from the Blue Square Bet Premier leaders, they could have been out of it by half time.
Jay Harris shot over from the edge of the penalty area before Richard Lee denied Cieslewicz and Lee Fowler curled an effort over.
Jake Speight volleyed wide as he tried to finish off a fine breakaway move before the visitors grabbed the lead they deserved just past the half hour - and in some style.
A corner was half cleared to Tolley on the edge of the penalty area and he lashed a shot back past Lee and in to the top corner from 25 yards.
It was no more that Wrexham deserved, they made their extra man in central midfield count and stretched The Bees with pace on the flanks.
Mike Grella had an early shooting opportunity, only to be denied by a fine tackle by Knight-Percival and got in behind the Wrexham defence last in the half before Mark Creighton got back to make a fine tackle.
Sam Saunders brought a superb save out of Joslain Mayebi in the Wrexham goal with a curling free kick, Harlee Dean had a header blocked and Leon Legge headed wide.
But Brentford were very much second best and could have gone in further behind - Lee held a looping Tolley header before Cieslewicz shot well over after good work by Danny Wright.
Legge flicked a header wide late in the half for Brentford, but the home side would have been well aware they needed to improve after the break.
Manager Uwe Rösler brought on Emmanuel Oyeleke for his professional début at half time, along with Niall McGinn, but Wrexham had the early chances in the second period.
A free kick fizzed across the six-yard box before Tolley fired over and when Creighton headed a Neil Ashton corner back, Knight-Percival's acrobatic effort bounced inches wide.
Cieslewicz could have wrapped it up when he capitalised on a Craig Woodman error and raced clear, but his shot flew just past the far post.
Brentford started to improve as the game headed towards the hour mark, and Wrexham started to retreat.
Gary Alexander shot just wide after a good turn on the edge of the box, Toumani Diagouraga's overhead drifted over the bar and Saunders had a curling effort deflect just wide.
Oyeleke was just unable to turn in a loose ball from a Saunders corner and Alexander headed straight at Mayebi from a superb Shaleum Logan cross.
Cieslewicz had shot blocked and then fired just wide following a break but most of the action was at the other end.
Mayebi kept out a cross-cum-shot from McGinn before the Northern Ireland international shot wide and a Diagouraga header deflected in to the arms of the goalkeeper.
As the match entered the final 15 minutes, it largely being played in Wrexham's defensive third - Mayebi pushed an effort from McGinn past the post and from Saunders' corner, Legge had a header blocked, then a shot blocked before the visitors got another body in the way to stop a McGinn effort.
Saunders fired well over and Harlee Dean had a header saved as Brentford pushed without finding a way through.
A combination of Mayebi and Neil Ashton just about kept out a Saunders free kick and Legge headed over as the game ticked towards its climax.
And when four minutes of stoppage time had been played, referee Roger East brought the game, and Brentford's cup run, to an end.
Brentford: Lee; Logan, Legge, Dean, Woodman (sub Donaldson 81 mins); Saunders, Diagouraga, Douglas, Weston (sub Oyeleke h/t); Grella (sub McGinn h/t), Alexander
Subs (not used): Devlin, Eger, Reeves, Bean
Wrexham: Mayebi; Obeng, Creighton, Knight-Percival, Ashton; Cieslewicz (sub Morrell 83 mins), Harris, Fowler, Tolley, Speight (sub Pogba 68 mins); Wright
Subs (not used): Maxwell, Hunt, Little, Westwood
Bookings: Mayebi (90 mins)
Attendance: 3,452 (731 away fans)
By Chris Wickham