Stalin had a very powerful position as General Secretary of the Communist Party. He could appoint people to posts and had control of the membership of the party. Between the years 1922-1924, he raised more of his own supporters to higher positions and expelled the younger and more radical elements which were likely to support Trotsky.
Stalin gained many more advantages than Trotsky, for example at Lenin’s funeral, in which at the time Trotsky was ill and Stalin tricked him into not coming, and so people thought he couldn’t even be bothered to go while Stalin made a big speech praising Lenin, claiming he was his disciple.
There was a great struggle for power between 2 wings of the party (left and right), and Stalin was in the middle. It was a battle of ideas as well as people.
Left Wing- Zinoviev and Kamenev were old Bolsheviks who shared the same ideas as Trotsky, but they did not support him as they were worried he was to become a dictator. This side of the party wished to end NEP and to quicken the pace of industrialization using shock brigades of workers and force the peasants to produce the food they needed
Right Wing- Bukharin had one of the best and most intelligent brains of the party. He was certain that the NEP was the way to progress, and to move forward. He thought that if the peasants became richer, they would buy more goods, which would help the industry grow. The right wing wanted to move slowly towards socialism.
Stalin kept gaining more advantages as the time went by, as the leading communists decided no to make Lenin’s testament public as it contained many criticisms of them and Stalin. In 1924 at the first Party Congress after Lenin’s death, Zinoviev and Kamenev joined forces with Stalin to defeat Trotsky. Since Stalin was the Party Secretary, he made sure that his supporters packed the Congress. Trotsky lost all the votes and soon after he lost his job as Commissar for the War.
In 1926, Stalin turned against Zinoviev and Kamenev, to join forces with Bukharin and the right wing. Once again he made sure his supporters packed the Congress and again he easily won the votes on important issues. Zinoviev and Kamenev lost their jobs in the Politburo, and in 1927, Trotsky, Zinoviev and Kamenev were expelled from the Party. Finally Stalin turned on Bukharin and the right wing Party and attacked the NEP, and he had them all removed from their posts. In 1929, Stalin celebrated his 50th Birthday as the undisputed leader of the USSR.
Unfortunately for Trotsky, he had many weaknesses and Stalin was always gaining advantages and making the right moves. Trotsky has lots of bad luck. But he was also disliked by his colleagues since he was claimed to be arrogant, snobbish, too intellectual and superior. Things like the fact that Trotsky didn’t even show up to Lenin’s funeral also was a huge setback in him being successful. I believe Stalin was a much more dedicated man who really reached out for what he believed in, and he was very cunning who knew what he had to do to win and would do it at any cost even if it meant messing up someone else’s life. Any obstacle in his way had to be taken out. He was more organized and had planned his overcoming, whilst Trotsky was too convinced and did not see Stalin as an obstacle in his path to success.