Lloyd James, Darius Henderson and Josh Wright scored for the home side while Gills replied with a brace by Cody McDonald and a goal from Jermaine McGlashan.
In a game with so many chances for both sides, it was the O’s who opened the scoring when winger Ryan Hedges was tripped in the box and James stepped forward to slam the ball into the net from the penalty spot.
Gillingham responded with two goals in eight minutes after some abject marking by the hosts.
McGlashan found himself unmarked three yards out when he turned in a Luke Norris cross after 35 minutes. Then Bradley Dack delivered a cross from the right and the unmarked McDonald was given the freedom of the penalty box to steer his header into the net from 10 yards.
Gills appeared to have sewn the game up when McDonald converted a penalty after Shane Lowry had upended Luke Norris after 56 minutes but Orient responded positively.
Substitute Henderson slammed home a rebound after 67 minutes after his first attempt had been blocked by goalkeeper Glenn Morris and the home side levelled with five minutes left when Wright collected a pass from Henderson to beat Morris with ease.