An abbreviation for the German phrase Geheime Staatspolizei (English: Secret State Police), the Gestapo was the political police organization of Nazi Germany. While it was a government organization, it was subordinate to the Reich Main Security Administration (RSHA, German: Reichssicherheits Hauptamt) of the Nazi Party.
The RSHA, which in turn was responsible to the Schutzstaffel (SS), a historical name for the Party "Security Squadron", but also to the State Ministry of the Interior. In practice, the SS, under Heinrich Himmler was in control. Nevertheless, the dual reporting, state and party, was common, as the lines of control converged only with Adolf Hitler. Similar parallel state and party structures existed in the Soviet Union under Josef Stalin.
Before the consolidation of offices under the Third Reich, there was a Secret Police Office, Geiheime Staatspolizeiamt or "Gestapa", under Prussia, headed by Hermann Goering. In 1936, it was transferred to national control and the "office" part was deleted from the name; the name that was to inspire dread was the contribution of a German Post Office worker asked to make up a rubber stamp for an abbreviation of the new organization name, hence "Gestapo". Himmler was deputy chief of the Gestapo, but never directly commanded the Gestapo, which was two levels of command below him.
The Gestapo had unlimited powers of arrest and detention, with the only official appeal being within the Gestapo itself. If one were lucky enough to have high connections, there might be other alternatives, but it was very unlikely. In some cases, however, there would be a jurisdictional issue; the Gestapo had limited powers against military personnel, although that reduced when German military counterintelligence, the Abwehr, was later dissolved. While it would act for a much wider range of reasons, it did participate in counterintelligence, although the Sicherheitsdienst (SD) was the active counterespionage organization.
Th greatest Gestapo power was "Schutzhaft", or "protective custody," based on the law passed in February 1933, which suspended the Weimar Constitutional constitutional guarantees of civil liberties. While, in some cases, prisoners of the Gestapo were put on formal trial, the Gestapo itself was not subject to judicial review.
Contrary to some cinematic impressions, there was no Gestapo uniform; they worked in plain clothes and had only an inconspicuous numbered disk as a credential.
It was a State, not Party organization, but reported to the Reich Main Security Administration (Reich (RSHA), under Reinhard Heydrich and then Ernst Kaltenbrunner. Throughout its existence, it was commanded by Heinrich Mueller.
According to the International Military Tribunal, its 1943 organization consisted of five headquarters sections, plus regional offices. 
German local offices
In the typical Nazi overlapping and conflicting chains of command, the regional offices within Germany reported directly to the RSHA in Berlin, but were subject to the supervision of Inspekteurs of the SIPO (Security Police) in the various provinces; these supervisors, in principle, managed cooperation between the Security Police (SIPO) and the central offices of the general and interior administration. In practice, there could be much bureaucratic fighting.
Offices in occupied territories
In the occupied territories the regional offices of the GESTAPO were coordinated with the Criminal Police and the SD under Kommandeurs of the Security Police and SD, who were subject to Befehlshabers of the Security Police and SD who reported to the Chief of the Security Police and SD (RSHA) in Berlin. In many areas, there was yet another intermediate echelon of Higher SS and Police Leader (German abbreviation HSSPF)
While the services were organized differently, there were parallels between the Gestapo and the Soviet Organs of State Security.