The 59-year-old Dutchman's contract was due to run out in 2012 but he agreed in a meeting on Monday that he would depart at the end of the current campaign after Bayern slipped to fifth in the Bundesliga standings.
"I plan to have a sabbatical year starting in the summer. It is sad that I cannot continue my work here," Van Gaal told reporters on Friday ahead of Saturday's match against Hamburg SV. "Maybe it is better for the club now that I am going."
Van Gaal had shown interest in taking over a national team after he was done at Bayern but said so far "unfortunately no one has called."
"I came to Bayern because it is a top team," the former Barcelona, Ajax Amsterdam and Netherlands coach said. "I love this culture, I love the fans and the fans love me. That is why I am sad I cannot continue here."
After winning the domestic double and reaching the Champions League final last year, Van Gaal extended his contract to 2012 in September.
However, a poor domestic season and a 3-1 defeat at Hanover 96 on Saturday, Bayern's third consecutive loss in all competitions and their worst losing run since 2000, sealed his fate.
Despite their German Cup exit, also last week, Bayern are still in the Champions League, facing Inter Milan in the return leg of their last 16 tie next week after winning 1-0 in Italy.
"I want to leave the club with my pride intact. I hope I can leave through the main entrance because we are talking about my honour," he said.
It was not only on the pitch that Van Gaal had problems. He was involved in a very public war of words earlier this season with club president Uli Hoeness who called Van Gaal a "one-man show" saying he would never take any advice.
On Friday he took a swipe at Bayern's bosses saying: "Bayern Munich is bigger than Van Gaal but also bigger than the club board."
Get the best features, fun and footballing frolics straight to your inbox every week.
Thank you for signing up to Four Four Two. You will receive a verification email shortly.
There was a problem. Please refresh the page and try again.