Brentford have defied expectations in their first season under Keith Andrews, but their home form – so impressive in the first half of the campaign – was starting to become a worry.
Andrews' side had not tasted victory in front of their own supporters since beating Sunderland 3-0 in January, although they had lost only two of their previous six games on home soil.
The Bees rode their luck at times but, like West Ham, should have scored more, with Mikkel Damsgaard and Igor Thiago both missing clear chances.
Sepp van den Berg flashed a header wide late in the first half, but El Hadji Malick Diouf's foul on Dango Ouattara – and Thiago's penalty – settled Brentford nerves.
Most fans would be thrilled at the prospect of Conference League football next season, but sixth spot will be enough for a place in the Champions League if Villa win the Europa League and finish fifth in the Premier League.
Whatever happens, it promises to be an exciting end to the campaign for Andrews and his players.