In the early 1930s, there was a concerted effort on the part of Adolf Hitler and his Nazi Party to consolidate power. The back end methods of this consolidation are well taught and well known, fear, intimidation, and street violence. However, the front part, the legitimate part, is less studied by the majority of the public.
Knowing that his radical Nazi party was in a precarious position electorally, Hitler set out to bring centrist parties into the fold. One such party was the Centre Party which had long been a bastion for political German Catholics. Hitler aimed to reduce the political power of the Catholic Church while receiving an international agreement with the Holy See. He achieved both brilliantly.
On their faces, it does not seem like the Pope and the Nazis would have much in common, and in many cases, they did not. There was one binding similarity between the two that brought them close together in the early 1930s: hatred for communism.
Both the new Nazi government in Germany as well as the Vatican in Italy were both publicly and diametrically opposed to communism. The Nazis were opposed to it for political reasons while the Catholics were opposed for religious reasons. Communism was a completely atheist system which had cracked down on Christianity in Russia and elsewhere leading to alarm in Vatican City.
(As a side note, the Papacy would remain staunchly anti-communist all the way through the Cold War.)
In 1933, Pius XI and one of his top advisors, Eugenio Pacelli who would succeed Pius XI as Pius XII, signed the Reichskonkordat with Germany. This sweeping document paved the way for Hitler to sweep the Catholic influence in Germany aside while giving him an international political victory on the world stage.