I was reminded by today's Google Doodle of Chiune Sugihara, the "Japanese Schindler" who saved thousands of Jews by giving them valid visas to travel through Japan.
How was he able to do this if Japan was an Axis Powers country, allied with Nazi Germany?
A few important things to note:
Japan didn't officially ally itself with Germany until the signing of the Tripartite Plan at the end of September 1940. Prior to that, Japan had prohibited the expulsion of Jews from its territories in accordance with its principles of equal treatment of racial minorities (in 1938). Sugihara was active until he was withdrawn from his post at the beginning of September 1940- three weeks before the signing of the Tripartite Plan.
The Japanese were interested in keeping Jews around as they had imbibed ideas about "Jewish money" and "Jewish power" in their dealings with Russian and were interested in seeing how those ideas could be used for their nation's benefit. They also wanted to maintain good relations with the US (who weren't in the war yet and who were at that time focusing trade embargos on Japan due to its occupation of French Indochina and its war with China) and thought that the perception of being a refuge for Jews would help the "powerful Jews" in the US to influence the US in their favor. This idea, of course, faded after first the signing of the Tripartite Plan and then Pearl Harbor.
Even after Japan was allied with Germany, it did not participate in the extermination or deportation for extermination of Jews. This is despite the fact that Germany had developed the Meisinger Plan, a plan to exterminate the Jews of Japan and Japanese-controlled China. While the Jewish refugees in Japan were eventually (in 1943) deported to the Hongkou neighborhood of Shanghai, they (as well as the prewar German refugees who were already in Shanghai and were also confined to Hongkou) were never in danger of being murdered, though the conditions in Hongkou were often extremely poor.
Even so, Sugihara technically wasn't able to allow so many Jews to pass through Japan- he received a great deal of pushback from his superiors and gave out the visas in spite of this. The Japanese reluctance to issue visas wasn't due to the fact that the applicants were Jews, it was because they didn't fit the financial criteria and hadn't gone through the proper channels.