The Ansar (Arabic: الأنصار, romanized: al-Anṣār, lit. 'The Helpers’ or ‘Those who bring victory') were the local inhabitants of Medina who, in Islamic tradition, took the Islamic prophet Muhammad and his followers (the Muhajirun) into their homes when they emigrated from Mecca during the hijra.
They belonged to the tribes of Banu Khazraj and Banu Aus.
Further information: Medina § History
The Medinese, which consisted of Aws and Khazraj, along with their Jewish allies, Banu Nadir, Banu Qurayza, and Banu Qaynuqa, were involved in degenerating years of warfare such as battle of Sumair, battle of Banu Jahjaha of Aus-Banu Mazin of Khazraj, battle of Sararah day, battle of Banu Wa'il ibn Zayd, battle of Zhufr-Malik, battle of Fari', battle of Hathib, battle of Rabi' day, first battle of Fijar in Yathrib (not Fijar war between Qays with Kinana in Mecca), battle of Ma'is, battle of Mudharras, and second battle of Fijar in Yathrib. The Medinese also even contacted against foreign invaders came from outside Hejaz, including such as Shapur II of Sasanian Empire in relatively vague result, and also in successful defense against Himyarite Kingdom under their sovereign, Tabban Abu Karib, who also known as Dhu al-Adh'ar. However, the most terrible conflict for both Aws and Khazraj were a civil war called the battle of Bu'ath, which leave bitter taste for both clans, and caused them to grew weary of war, due to the exceptionally high level of violence, even by their standards, and the needless massacres that occurred during that battle.
Thus, in search of enlightenments and seeking arbitration from third party, the Yathribese then pledge their allegiance to Muhammad, a Qurayshite Meccan who preach new faith of Islam during the Medinese pilgrimage to Kaaba time. As Muhammad managed to convince many notables of both Aws and Khazraj, which also included Abbad ibn Bishr who personally convinced by a Muhajirun named Mus'ab ibn Umayr of his cause on his new faith, the chieftains of both Aus and Khazraj tribe, particularly Sa'd ibn Mu'adh, Usaid Bin Hudair, Saʽd ibn ʽUbadah, and As'ad ibn Zurara agreed to embrace Islam and appoint Muhammad as arbitrator and de facto leader of Medina. In no time, Abbad and other Yathribese agreed to provide shelter for Meccan Muslims who has been persecuted by Quraysh polytheists, while also agreed to changed their city name from Yathrib to Medina, as Yathrib has bad connotation in Arabic.
Main article: List of expeditions of Muhammad
The Ansar helped Muhammad in several battles. One of the earliest battles they helped him in was the Patrol of Buwat. A month after the raid at al-Abwa that was ordered by Muhammad, he personally led two hundred men including Muhajirs and Ansars to Bawat, a place on the caravan route of the Quraysh merchants. A herd of fifteen hundred camels was proceeding, accompanied by one hundred riders under the leadership of Umayyah ibn Khalaf, a Quraysh. The purpose of the raid was to plunder this rich Quraysh caravan. No battle took place and the raid resulted in no booty. This was due to the caravan taking an untrodden unknown route. Muhammad then went up to Dhat al-Saq, in the desert of al-Khabar. He prayed there and a mosque was built at the spot. This was the first raid where a few Ansars took part. 
During the tenure of Caliphates after Muhammad, the Ansar mainly became important military elements in many conquests, (as indicated with the appointing of Thabit, bin Qays bin Shammas, an orator of Ansar), to lead Ansaris in support of Khalid ibn al-Walid in the Battle of Buzakha at the time of Caliph Abu Bakr. Later they also played a prominent role in the Battle of Yamama where Ansars under Al Bara bin Malik Al Ansari charged at a perilous moment of the battle marking its turning point. The battle of Yamama is also where the Ansar's most prominent warrior, Abu Dujana, fell.
During the caliphate of Umar, prominent Ansaris contributed greatly during campaigns against Byzantium. The Ansari chief 'Ubadah ibn al-Samit particularly played many significant roles during Muslim conquest of Egypt and Muslim conquest of Levant under the likes of Abu Ubaydah, Khalid ibn Walid, Amr ibn al-Aas, and Muawiyah
In the year 24/645, during the caliphate of Uthman Ibn Affan, prominent Ansaris also held major positions like Al-Bara' ibn `Azib who was made governor of al-Ray (in Persia). He eventually retired to Kūfā and there he died in the year 71/690.
During the Umayyad era the Ansar became somewhat of an opposing political faction of the regime. They are described as closely affiliated with the Hashim Clan Contingent rather than with the incumbent Umayyad. Such Ansar-Hashim connections are described as forming a new elite local political hegemony in Hejaz.
Sahih Bukhari; Sahih Muslim; Siyar A'lam Nubala
The second Pledge of Al-'Aqabah (the pledge of war) was: "Blood is blood and blood not to be paid for is blood not to be paid for. I am of you and you are of me. I will war against them that war against you, and be at peace with those and peace with you"