One of the main reasons why Hitler occupied Hungary directly before the end of the war, and why Germany fought so tenaciously to keep the Soviets from over-running Budapest, was that many Jews fled from Germany, Czechoslovakia, Poland, and Austria to Hungary. At one point, Hungary had more Jews than any nation in Europe.
Under pressure from Hitler, Hungary passed anti-Semitic laws, but generally only half-way measures compared to what Hitler insisted upon. When Hitler demanded that Jews be outlawed, Hungary enacted legislation making it illegal to practice the religion in an organized manner. When Hitler demanded that Jews be excluded from certain professions, Hungary restricted the percentages of Jews in some of those fields. Hungary sent a group of Jews to Germany for "work details" as requested, but refused to send more until the first group was returned. Eventually, Hitler tired of the constant foot-dragging and passive resistance, and occupied the country directly, citing the threat of armed Jewry poised at the throat of Germany as the justification for the invasion. When the Soviets invaded Hungary, Hitler devoted an inordinate amount of military force to slowing the advance, in order to buy time to continue rounding up more of the refugee Jews from the rest of Europe, from where they were sheltering mainly in the Budapest area.
If you want more information, the book "Hungary, the Unwilling Satellite", written by the US ambassador to Hungary at the time, goes into a lot of detail, and explains why Hungary did what it did, in order to (unsuccessfully) stave off occupation without having to sacrifice its minorities to Hitler's program of destruction. He points out that, while some Hungarians were complicit with Germany, more were willing to help the refugees find housing and work. He also points out that Hitler's plans were not completed in Hungary, with the result that hundreds of thousands more may have survived than if Hungary had taken a defiant but hopeless stance against Hitler from the start. Regent Miklos Horthy was described as willing to let Hungary bend in order not to break. Today, he is reviled by many as a complicit anti-Semite, but his actions can also be viewed as doing the minimum amount of harm under the very difficult circumstances. He had nothing good to say about Hitler, and later testified against the Nazis on the issue in the Nuremburg war trials.
Trying to understand the politics and rationale behind those decisions and events is difficult or impossible without taking Hitler's personal hatreds into account.