Lyon, who move up to second on 59 points with five games left, opened the scoring through Lisandro Lopez but Younes Belhanda equalised before the break, only for Grenier to strike three minutes into stoppage time.
OL now occupy the last spot to reach the Champions League proper and lead third-placed Marseille, who host Stade Brest on Saturday, by a point.
They still trail runaway leaders Paris St Germain by eight points.
Montpellier's hopes of playing in Europe next season have almost vanished as they remain seventh on 48 points, trailing sixth-placed Lille by five points.
Lyon, who had ended a three-game losing streak by beating Toulouse last weekend, got off to a good start with Lisandro netting for the first time in over a month.
The Argentine striker headed home at the near post from a Grenier cross in the 29th minute.
Morocco midfielder Belhanda, however, levelled four minutes before the break with a low 20-metre shot.
Montpellier continued to press hard after the interval, but Anthony Mounier's clever lob went just over the bar shortly before the hour.
In the closing stages, Lyon goalkeeper Remy Vercoutre pulled off a save to deny Remy Cabella from close range, with the ball bouncing off the post.
Montpellier eventually paid dearly for their profligacy.
Attacking midfielder Grenier unleashed a powerful 25-metre shot from a bad clearance after his team had been awarded a last-chance corner kick.
On Sunday, in-form Lille, who are on 53 points after winning seven of their last 10 league games, travel to Bastia and PSG entertain Nice.