Both sides missed one of their first four penalties before Richard Smallwood put Rotherham 4-3 ahead. That meant Orient's Chris Dagnall had to score but his spot-kick was saved by Rotherham goalkeeper Adam Collin, earning the club promotion to the Championship.
Orient had gone 2-0 up after first-half goals from Moses Odubajo and Dean Cox, but Rotherham's Alex Revell netted a second-half brace against his former club as the match went to extra-time and then spot-kicks.
Orient went ahead in the 34th minute when Odubajo hit a superb 25-yard half volley from the edge of the box after Kari Arnason's poor clearance.
And Cox added a second for Orient five minutes later when Odubajo's low cross from the right was tapped in by the winger, with Rotherham's defending non-existent.
Rotherham assistant boss Paul Raynor was sent to the stands for the second half but it didn't seem to affect the Millers.
United's James Tavernier hit a 25-yard free-kick on to the roof of the net early in the second half and Ben Pringle then went close with his own free-kick.
But Rotherham made their pressure pay on 55 minutes when Revell tapped in from six yards after Orient goalkeeper Jamie Jones came for the ball but failed to collect it.
Revell then equalised for Rotherham on the hour mark with an angled, dipping half volley from 40 yards out - his 13th goal of the season.
Orient went close on 77 minutes when David Mooney just failed to get on the end of Lloyd James' cross.
Winger Kieran Agard then blazed high and wide for Rotherham after moving up front and headed wide in the final minute of normal time.
In the first half of extra-time Jones made a superb one-handed save to tip the ball over after Orient defender Scott Cuthbert headed towards his own goal.
Orient striker Mooney chipped the ball over and Nathan Clarke headed wide but neither team could find a winner as the match went to spot-kicks and Collin earned Rotherham promotion in dramatic fashion.