What, if any, set of laws were passed in Germany that gave the Nazis the power to detain, torture, experiment on, and execute the Jews in WW2? Did it even have a legal foundation within Germany (i.e., were the Jews "sentenced" to camps), or was it just something that party officials said "hey go do this"?
There was no legal basis for the killing, which is why Himmler said “this is a page of glory never to be mentioned”.
However, there were a whole slew of anti-jewish laws passed in Germany, and in the occupied countries the persecution was ordered through a series of decrees. The decrees generally followed the progressive escalation of measures taken in Germany before the war, only more rapidly, which is why I would like to take Belgium as an example and list all anti-Jewish decrees issued by the German occupier in their chronological order. It will give you an idea of why it wasn't immediately clear to the Jews or their fellow citizens that the end result of all this would turn out to be death.
Oct 23, 1940: ritual slaughter is prohibited on the grounds of animal cruelty
Oct 28, 1940: General measures against the Jews:
definition of a Jew
establishment of a Jewish register
Jewish companies have to declare their assets
Jewish cafes and restaurants have to be clearly labeled as such
Oct 28, 1940: Jews are barred from being civil servants or employed by the state, and barred from being judges, lawyers, journalists, and teachers (except in Jewish schools).
May 31, 1941: various economic measures: all Jewish businesses are to be labeled, no new Jewish companies can be established without permission, private assets have to be declared
August 29, 1941: restrictions on the free movement of Jews: establishment of a curfew, Jews can only live in Brussels, Antwerp, Liège and Charleroi.
Nov 25, 1941: establishment of the Jewish Council:
all other Jewish associations are prohibited
all Jews have to be a member of the JC
the JC is to “encourage emigration”
the JC is in charge of education and social security for the Jews
Dec 1, 1941: Jews may no longer attend regular schools
Jan 17, 1942: Jews may not travel abroad without permission
March 11, 1942: the Military Administration is in sole charge of the employment of Jews in Belgium
April 2, 1942: confiscation of the assets of German Jews living in Belgium
May 27, 1942: wearing of the yellow star is compulsory
June 1, 1942:
Jews are barred from the medical profession
further restrictions on the free movement of Jews
Aug 1, 1942 and Sep 21, 1942: further measures on the confiscation of Jewish properties
In July 1942 the first couple of thousand Jews received letters ordering them to assemble for “employment in the East”.
On August 4, 1942 the first train left for Auschwitz.
Source: Saerens, Lieven. Vreemdelingen in een wereldstad: een geschiedenis van Antwerpen en zijn joodse bevolking (1880-1944). Lannoo Uitgeverij, 2000.