Snoke, Supreme Leader of the First Order, was once a Jedi Knight, over 500 years before the Battle of Yavin. He was close friends with fellow Jedi Knight Yoda. The two discovered a Sith shrine underneath the Jedi Temple on Coruscant and Snoke was corrupted by the dark side forces emanating from it. Snoke and Yoda battled, and Yoda refused to kill Snoke, allowing the dark sider to flee Coruscant. Snoke fled to the Unknown Regions and met an ancient dark side spirit known as Abeloth, who had been contained millennia earlier and could not be freed from her imprisonment. She promised Snoke power in return for freeing her. He sought a way to do so, and began training acolytes to follow him. Over time, the Jedi Order became aware of Snoke's threat. Yoda, guilty over his failure to kill Snoke before, led a strike team to stop his old friend.
Snoke and his acolytes had gathered on the planet Jakku to study a ritual that would bring Abeloth out of her imprisonment. Yoda and his team arrived at the same time as two Sith Lords—the only two Sith at the time, who had heard of Snoke's plot and feared him enough themselves to come out of hiding to stop him. Snoke's acolytes were all killed, and Snoke himself was imprisoned by Yoda on Jakku. However, the Master of the Sith was captured by Yoda, while the apprentice escaped.
Centuries later, Snoke was freed during the Battle of Jakku, which ended the war between the Galactic Empire and the New Republic. He sensed a powerful presence at the battle and realized it was a Jedi Master. Snoke snuck off Jakku and began building a power base with the remnant of the Empire, which he named the First Order. Over time, he learned that the Jedi he'd sensed was named Luke Skywalker, and that Skywalker's sister, Leia Organa Solo, had a son. Snoke had the son kidnapped and had one of his Force-sensitive acolytes, Gavar Khai, raise the boy under the name Kylo Ren. Snoke began studying ways to free Abeloth, while planning to use Kylo Ren as his ultimate weapon in the battle with the Jedi.