A student one day went to his master and said, "Master, is there a heaven? Is there a hell?"
His master simply stared at him silently, saying nothing.
In a fit of rage, the student drew a sword from a nearby stand, and went to strike down his master for saying nothing
The master spoke softly, "Thus opens the path to Hell."
The student, in shock, lowered the blade, then dropped it at his feet and bowed to his master.
The master spoke, smiling, "And thus opens the path to Heaven"

This tale has also been retold as such-

A soldier named Nobushige came to Hakuin and asked, "Is there really a paradise and a hell?"
"Who are you?", asked Hakuin.
"I am a samurai.", the warrior replied.
You, a soldier!", exclaimed Hakuin. "What kind of ruler would have you as his guard? Your face looks like that of a beggar."
Nobushige became so angry that he began to draw his sword, but Hakuin continued, "So you have a sword! Your weapon is probably much too dull to cut off my head."
As Nobushige drew his sword, Hakuin remarked, "Here open the gates of hell!"
At these words, the samurai, perceiving the master's discipline, sheathed his sword and bowed.
"Here open the gates of paradise.", said Hakuin.

Edited: Fixed a typo in the comments, thanks Themanwho!