Bournemouth looked like avenging their 6-0 Johnstone’s Paint Trophy thrashing at the hands of Brentford last month with a deserved away win over the Bees.
Charlie Sheringham’s first league goal looked like settling it as he was given too much time in the penalty area to chest down and volley home in the 19th minute.
Brentford almost hit back within four minutes, but Gary Alexander’s header from a tight angle bounced to safety off the outside of the post.
Uwe Rosler’s side had to wait until the 94th minute to snatch a point, with Legge powering home a header from Clayton Donaldson’s right-wing cross.
Niall McGinn and Sam Saunders earlier saw efforts tipped to safety by Cherries goalkeeper Darryl Flahavan and until their last-gasp leveller Brentford rarely looked like drawing level, their best efforts coming when central defender Harlee Dean headed narrowly wide in the 88th minute.