Because of his previous incident with the Austrian military, he returned to Germany, the ally sister country, and volunteered to the German army.
After a short training, his unit was sent to the bloody battlefield in the trenches of the western front, and fought mainly against British forces. He fought bravely, narrowly escaped death several times, and was decorated twice with the Iron Cross medal, but not promoted. He was wounded twice in combat. In his 2nd injury he was temporarily blinded. During his recovery from his 2nd injury, still blind, in a military hospital, he was surprised and shocked with the news that the war ended with a German defeat.
It's important to note that during his years in the military, Hitler received political indoctrination that completed his 'political education', and made him a strong supporter of the 'eastern' militarist orientation. His cruel war experience, he later said, also developed in him an uncompromising iron will.
Post-war Germany was in chaos. Communism rose, and communist movements rioted in the cities, some of them led by Jews. Eventually Germany turned from a militarist monarchy to a democracy, with an executive prime minister and a president that kept powerful authorities, the replacement of the king. The socialists gained control of the government. The situation in the streets got worse. The new government finally signed the peace treaty that included loss of territory, a severe economical burden of compensations, and severe limitations on the German military's size and equipment, which were supposed to reduce its threat. Most Germans perceived it as a great national humiliation.
Hitler, finally recovered from his injury, and still officially a soldier, joined a Para-military militia of war veterans who clashed with the communists in the streets of German cities. He was then given the task of closely monitoring a tiny right-wing political group called 'German Worker's Party'.