This famous quote is from the Eleventh Chapter of the Bhagavad-gita, entitled Visva-Rupa-Darsana-yoga, or the "Yoga of Theophany", the chapter in which Krishna displays His Universal form--His divine Opulence--to Arjuna.

In full, the verse is as follows:

sri-bhagavan uvaca:
kalo 'smi loka-ksaya-krt pravrddho
lokan samahartum iha pravrttah /
rte 'pi tvam na bhavisyanti sarve
ye 'vasthitah pratyanikesu yodhah //

The Lord said: "Time [death] I am, the destroyer of the worlds, who has come to annihilate everyone. Even without your taking part all those arrayed in the [two] opposing ranks will be slain!"

(Gita vs. 11.32
trans. after Swami Tripurari)

Some translators, including Bhaktivedanta Swami render rte 'pi tvam ("Even without your taking part..."), as "With the exception of you [the Pandavas]...". Either interpretation is valid in this context. In his Prakasika-vrtti commentary, Srila Narayana Maharaja of the Gaudiya Vedanta Samiti in Mathura explains:

Sri Bhagavan tells Arjuna, "I am all-destroying time and at present I have accepted this gigantic form. I am present here to annihiliate Duryodhana and others. The result of My mission will be that, except for you the five Pandavas, no one on this battlefield will remain alive. Even without your endeavour of the efforts of other warriors like you, all will be devoured within the jaws of terrible time, because in My form as time I have already taken their lives. Those heroes who are present on both sides will definitely enter the mouth of death, even without doing battle. Therefore, O Arjuna, if you remain aloof from the battle, you will fall down from your status as a ksatriya because you have neglected your sva-dharma and still they will not be saved."