Danny Kedwell's goal was enough for Gillingham to beat struggling Torquay and seal promotion to League One.
The striker scored just after half time when he showed strength to latch on to a long diagonal ball and fire across Torquay goalkeeper Martin Rice.
Gills striker Adam Birchall hit the bar in the third minute and Torquay's Rene Howe saw a shot hit the post before Adam Barrett cleared off the line.
A late free-kick from Kevin Nicholson rattled the bar but the Gills held on.
The final whistle sparked jubilant scenes at Priestfield as Gillingham, who have been top of the table for the majority of the season, sealed their first ever promotion on home soil in what is their centenary year.
With Rotherham and Northampton both losing, Kedwell, a Gillingham supporter, hit his 15th goal of the season to help the Kent club return to the third tier for the first time since 2010.
Torquay have now lost their last three games and only goal difference is keeping them out of the relegation zone.
Bottom of the table Aldershot Town are two points behind the Gulls and have two games in hand on the Plainmoor outfit.
VIEWS FROM THE DRESSING ROOM
Gillingham manager Martin Allen told BBC Radio Kent:
"Amazing feeling. The announcement that came over the whole ground [that Rotherham were losing] was a spooky, eerie couple of minutes, and the crowd and all of us went pretty quiet. We couldn't wait for that game to end.
"Between the three of us [Allen's management team] before the end of the game we had a hug.
"It's been a team effort on and off the field - and we have to mention all the players who've played for us through the season on loan or who've left. They've played their part as well.
"We're a work in progress, we're not finished yet, that's for sure."
Torquay United manager Alan Knill told BBC Radio Devon:
"Even though they had a lot of ball and they put a lot of balls into our box I thought we looked dangerous on the counter-attack.
"You've got to come out and keep the crowd quiet for 20 minutes and two minutes after the break they scored, so it made it difficult.
"Full credit to the players - they kept going and we hit the bar but it just wasn't to be.
"I thought we were committed today and we have to be for the next three games. I think we will comfortably stay up and it is important everybody is with us."