"I find it very thrilling to be playing against the best team in Europe," Bayern chairman Karl-Heinz Rummenigge said.
Seeking its fourth title in eight years, Barcelona opens at Bayern on April 23 in a matchup of runaway league leaders, then hosts the second leg on May 1. Real Madrid starts at Dortmund on April 24 and is home on April 30.
The draw avoided a rematch of the foul-filled 2011 semifinal between the Spanish powers, won by Barcelona on 3-1 aggregate.
Real Madrid defeated defending champion Dortmund 2-0 in the 1998 semifinals, winning the first leg 2-0 at home.
"I don't have to repeat that Real is a difficult opponent, but from the three possible opponents Real is the only one we've beaten this season," Dortmund coach Juergen Klopp said.
The winners meet in the final on May 25 at London's Wembley Stadium, where Barcelona beat Manchester United in the 2011 final.
In the second-tier Europa League, Chelsea meets Basel and Fenerbahce plays Benfica. The Swiss and Turkish teams are hosts for the first leg April 25, and the second legs are May 2.