The present invention provides a nitrogen-containing heterocyclic derivative which has ASK1-inhibitory activity and is useful as a prophylactic and/or therapeutic agent for ALS and so on, or a pharmaceutically acceptable salt thereof. The present invention provides a compound selected from among compound (1), compound (2), compound (3), compound (4), compound (6), compound (7) and compound (8), or a pharmaceutically acceptable salt thereof.