Huddersfield's Danny Schofield and Andy Booth both scored in injury-time to snatch a dramatic win for the Terriers.
Andy Booth grabbed victory six minutes into injury-time
Isaiah Rankin put Brentford ahead with a superb shot but Pawel Abbott cleverly chipped Stuart Nelson to level.
Brentford brought on Dudley Campbell at half-time and within 30 seconds he had turned in Jay Tabb's cross for 2-1.
Town's Tom Clarke and Brentford's Andy Frampton were sent off for two bookings before Schofield's shot and Booth's 96th minute close-range header won it.
Huddersfield: Rachubka, Holdsworth, Tom Clarke, Nathan Clarke, Adams, Brandon (Mendes 65), Schofield, Worthington, Carss, Abbott, Taylor-Fletcher (Booth 65). Subs Not Used: Senior, Collins, McCombe.
Sent Off: Tom Clarke (80).
Booked: Tom Clarke, Holdsworth.
Goals: Abbott 34, Schofield 90, Booth 90.
Brentford: Nelson, Tillen, Turner, Frampton, Fitzgerald (Campbell 45, Peters 90)), Gayle, Lewis, Pratley, Tabb (Owusu 82), Sodje, Rankin. Subs Not Used: Brooker, Bankole.
Sent Off: Frampton (85).
Booked: Frampton, Tabb, Turner.
Goals: Rankin 23, Campbell 46.
Ref: E Ilderton (Tyne & Wear).