Marcelo Trotter hit the bar with a penalty in added time, which allowed Doncaster to score the winner from the resulting break.
The result means that Doncaster are champions of League One and will return to the Championship, while Brentford have to settle for a playoff place.
Colchester beat Carlisle 2-0 to stay in League One and condemn Scunthorpe to relegation after eight successive years in the third tier.
Scunthorpe came from behind to beat Swindon Town 3-1, but the win wasn't enough to save them from relegation.
Results in full: Brentford 0-1 Doncaster, Bury 3-2 Yeovil, Carlisle 0-2 Colchester, Crawley 2-2 Hartlepool, Crewe 2-0 Walsall, Leyton Orient 1-1 Oldham, Notts County 2-2 Coventry City, Scunthorpe 3-1 Swindon Town, Sheffield United 0-0 Preston North End, Stevenage 0-2 MK Dons, Tranmere Rovers 0-0 Bournemouth