An heir is someone who inherits, or is designated to inherit, the property or position of another without an external cause like purchase and sale, dedication etc. rather by descent and right of relationship.
In the holy verses of the Quran, Yahya and Sulayman have been considered as the heirs of Zakariyah and Dawood, respectively.
It has been clearly stated in our traditions that Ali was introduced as the heir and successor of the Apostle of God (pbuh). For instance, Khalid bin Qathm, the grandson of Abbas (the Uncle of the Holy Prophet peace be upon him) was asked: "Why is Ali the heir of the Apostle of God (pbuh) and why isn't your grandfather, Abbas, the uncle of the Prophet [who is apparently closer to him by descent] his heir?
He answered: "That is because Ali is the first person who accepted the prophetic mission of the Prophet and he accompanied him more than we accompanied him." Hence, the sentence "Ali warith" [Ali is the heir] has been extracted from Shia and Sunni sources and it is in clear conformity with Muslims' beliefs, and it is not in any way opposed to their beliefs."
THE MEANING OF "WARIS" [Heir]
Before explaining the meaning of "Warith", we must explain the meaning of inheritance with reliance on various sources.
Raghib Esfahani says: "Inheritance is a property that passes to the heir on the death of the owner without an agreement or contract. It is the estate which is left by the deceased person."
It has also been said that "inheritance is the property which becomes the property of another person upon the death of the owner by descent or causal relationship." And some have also said: "Inheritance is the transference of a property to you without purchase and the likes. For this reason, a property left by the deceased is called mirath, irth and turath. Allamah Tabarsi has said: "Mirath (inheritance) is the property that passes to another person on the death of the owner." 
However, the Arabic word "Irth" has a wide range of meanings in the Quran. It includes inheritance of both estate as well as spiritual positions as shall be explained later.
Having explained "irth", the meaning of "warith" which is a derivative of the former will also become clear. Hence, "Warith" is a person who inherits a property or a position on the death of another person without external cause like purchase and sale, dedication etc. rather by descent and right of relationship.
"Warith" in the Quran
God quotes Hazrat Zakariya in the Holy Quran as such:
"Now I fear (what) my relatives (and colleagues) (will do) after me: but my wife is barren: so give me an heir as from Thyself, - (One that) will (truly) represent me, and represent the posterity of Jacob; and make him, O my Lord! one with whom Thou art well-pleased!"
Else where in the Quran He says: And Sulyman was Dawood's heir."
In the foregoing holy verses of the Quran, Yahya and Sulayman have been considered as the heirs of Zakariyah and Dawood, respectively.
"Warith" in Sunni and Shi'ah Traditions
A) Khalid bin Qathm, the grandson of Abbas (the Uncle of the Holy Prophet peace be upon him) was asked: "Why is Ali the heir of the Apostle of God and why isn't your grandfather, Abbas, the uncle of the Prophet [who is apparently closer to him by descent] the heir?
He answered: "Because Ali was the first person who accepted the prophetic mission of the Prophet and he accompanied him more than we accompanied him."
It is worth mentioning that according to Hakim Neishabouri, this hadith is authentic.
B) A man said to Ali: "O Commander of believers, how did you become the heir of your cousin to the exclusion of your paternal uncle?" Ali said:"Ahem" three times until every body craned their necks and pricked up their ears, and then said "Prophet invited the whole of the Banu Abd al-Muttalib, including his own closest relatives, to eat a year old lamb and to drink some milk. He also prepared a quantity of wheat for them, and they ate until they were full, while the food remained as it was, as though it had not been touched. Then he called for a drinking cup and they drank until they could drink no more, while the drink remained as though it had not been touched and they had not drunk. Then he said Banu abd al Muttalib, I have been sent to all men in general and to you in particular. Now that you have seen what you have seen, which of you will swear an oath of allegiance to me to become my brother, my companion, and my inheritor? Not one of them rose up, so I stood up before him even though I was the youngest there. He said Sit down. He repeated the words he had spoken for three times while I would rise up and he would say to me sit down. On the third occasion, he struck his hand on mine. In this way I became the heir of my cousin to the exclusion of my uncle."
C) It has been narrated from Salman that he asked the Prophet: "O' Apostle of God, who is your successor?"
The Prophet said: "Who was the successor of my brother, Musa?"
Salman answered: "Yusha' bin Noon. (Joshua b. Nun)"
The Prophet then said: "My successor and heir who shall fulfill my obligation and carry out my promise is Ali bin Abi Talib."
D) Also, the Prophet (pbuh) has been quoted as having said: "Every prophet has had a successor and an heir, and my successor and heir is Ali bin Abi Talib."
E) In the incident of brotherhood contract between the Prophet (pbuh) and his companions in which Ali remained alone and got upset, the Prophet (pbuh) told him: "By Allah, Who appointed me a prophet, I have kept you for myself and you are to me like Harun to Moses except that there is no prophet after me, and you are my brother and my heir …"
Therefore, in view of the foregoing points especially the narrations which have been reported by the narrators of both the sects and considering that the Commander of the Faithful (a.s.) inherited the spiritual rank of the Holy Prophet (pbuh), there is no objection in saying "Ali Warith" as it is in conformity with Muslims' beliefs.
 - Raghib Esfahani, Hussein bin Muhammad, Al-Mufradat fi Gharib al-Quran, pg. 863, Darul Ilm, Al-Dar al-Shamiyah, Damascus, Beirut, 1412 A.H.
 - Mustafavi, Hasan, Al-Tahqiq fi Kalimat al-Quran al-Karim, vol.13, pg.77, Translation and Publications Office, Tehran, 1981.
 - Qurashi, Sayyid Ali Akbar, Qamus-e Quran, vol.7, pg.195, Darul Kutub al-Islamiyah, Tehran, sixth edition, 1371 pg.
4] - Maryam (Mary): 5 & 6.
 - Al-Naml: 16.
 - Hakim Neishabouri, al-Mustadrak ala al-Sahihain Lil-hakim, vol.10, pg.439, Book source: Jame' al-hadith website: http: www.alsunnah.com ; Sunan Nesai, vol.5,
g.139, Book source: al-Islam website: http://al-islam.com
 - Nesai, Sunan Kubra, vol.5, pg.126.
 - Hilli, Hasan bin Yusuf, Nahjul Haq wa Kashf al-Sidq, pg.214, Darul Hijrah Institute, Qom, 1407 A.H. (quoted from Ahmad bin Hanbal and Ibn Maghazali Shafei).
 - Majlisi, Muhammad Baqir, Behar al-Anwar, vol.38, pg.346, Al-Wafa Institute, Beirut – Lebanon, 1404 A.H.