Josef Stalin was a master at establishing and maintaining control over the Soviet Empire, or at least, he became one. Under his iron-fisted rule, Stalin established a giant network of informers and secret police. In the beginning, when his hold over the country was tenuous, he ordered mass arrests of Ukrainians, Poles, Latvians, Lithuanians, Estonians, Kazakhs and a fictional class of people he created, the Kulaks. Literally hundreds of thousands of people were arrested and deported to Siberia.
To house this mass of prisoners (that eventually numbered close to 3 million), an entire system of concentration and labor camps were created, the Gulag. Mortality in these camps was high, and relatively few were ever released.
In addition, Stalin forcibly "collectivized" the peasant farms in theUkraine and elsewhere into Soviet collective farms. He arrested and deported thousands of them, and the resulting grain harvests dropped off dramatically. Still he required they fill their quota of grain for export. Mass starvation broke out, killing close to a million Ukrainians.
Millions more during his reign were arrested and executed for imaginary crimes against the state. This was usually carried out by the NKVD, his secret state police, and involved tens of thousands of people being shot and buried in mass graves. Some of these graves are still being discovered. This time was called The Great Terror.
By the late 1930s, few were remaining to present a challenge to his rule. Few would dare. Then he purged his military of half of his officers, even though they had done nothing wrong. Then he purged his police force and the Communist Party.
Essentially, he kept power by murdering all of his potential opposition.