Throughout the summer of 1939, Britain and France had attempted to reach an agreement with Stalin. However, these talks failed for a number of reasons:
purgesof the armed forces had led to the imprisonment or execution of many of its best officers
The British sent a naval admiral to the USSR to lead talks in August 1939. The Soviets noted that it was not a Government minister. They demanded that in event of a conflict, they should be able to enter Polish or Romanian territory.
The Poles refused to allow Soviet troops on to Polish soil. This was the major stumbling block. This drew the Soviet leader towards Hitler's offer of security.
German Foreign Minister Ribbentrop met with the Soviet Foreign Minister Molotov in Moscow. On 23 August 1939 they agreed a Non-Aggression Pact between their two countries.
This ended any chance of the USSR siding with the British and French in 1939. This was a major success for Hitler and it allowed him to begin the attack on Poland.
It also allowed the USSR the time to build up their military strength. Furthermore, Stalin saw both the liberal capitalist states (like Britain and France) and the fascist dictatorships (like Germany and Italy) as potential enemies.
Through the pact he thought to play them off against each other by giving Hitler a free hand to invade Poland and go to war against its Western allies without intervention by the Soviet Union.
We are not opposed to war [between Germany and the Western states] if they have a good fight and weaken each otherStalin, 1939
The Pact also had secret clauses. These allowed the USSR to occupy part of Poland after the German attack. It also allowed the Soviets to occupy Latvia and Estonia.
The Nazi-Soviet Pact came as a shock to many who could not believe that the two bitter enemies could reach an agreement.