Yes, Al-Al-Quran permits leaving Mina on the 12th after stoning all three Jamarat, but you must depart before sunset — if sunset catches you in Mina, you must stay and stone on the 13th.
Yes, Al-Al-Quran explicitly permits early departure from Mina: 'Whoever hastens [departure] on the second day (12th), there is no sin upon him; and whoever delays, there is no sin upon him — for the one who has taqwa (God-consciousness)' (Al-Quran 2:203). This early departure is called Nafr Awwal (first departure), while staying until the 13th is called Nafr Thani (second departure).
To leave on the 12th, you must: complete the stoning of all three Jamarat on the 12th in the correct order (after Dhuhr according to the majority), and then depart from Mina before sunset. The critical deadline is sunset — if the sun sets while you are still within the boundaries of Mina, the majority of scholars say you become obligated to stay the night and perform the stoning on the 13th as well.
Both options are equally valid with no sin attached to either choice. However, staying until the 13th and completing all the rites is considered more virtuous by the majority of scholars, as Nabi (shallallahu alaihi wa sallam) stayed until the 13th. Practically, early departure on the 12th also means less crowding when performing the farewell Tawaf in Mekkah, which is a consideration for large groups with fixed travel schedules. If you choose Nafr Awwal, do not delay after stoning — proceed to depart Mina promptly to avoid being caught by sunset.
فَمَن تَعَجَّلَ فِي يَوْمَيْنِ فَلَا إِثْمَ عَلَيْهِ وَمَن تَأَخَّرَ فَلَا إِثْمَ عَلَيْهِ
Whoever hastens departure from Mina in two days, there is no sin upon him; and whoever delays, there is no sin upon him — for the one who fears Allah.
Source: Ibn Kathir, Tafsir al-Al-Quran al-Azim; al-Nawawi, Al-Majmu
Whoever hastens departure from Mina in two days, there is no sin upon him; and whoever delays, there is no sin upon him — for the one who fears Allah.
Al-Baqarah (2:203)