According to Ibn Hajar al-Asqalani, scholars define a Companion as "a believer who saw and heard the Messenger at least once and died as a believer."  Even though some scholars have stipulated that a "potential" Companion should have lived in the Messenger's company for one or even two years, most scholars say it is enough to have been present in his radiant atmosphere long enough to derive some benefit from it.
Of course, the Companions are not equal to each other in rank or greatness. Some believed in the Messenger at the very outset of his mission, and conversions continued until his death. The Qur'an grades them according to precedence in belief and to conversion before and after the conquest of Makka (9:100; 57:10). The same gradation also was made by the Messenger. For example, he reproached Khalid for offending 'Ammar, saying: "Don't bother my Companions!"  He also frowned at 'Umar when he annoyed Abu Bakr, and asked: "Why don't you leave my Companions to me? Abu Bakr believed in me when all of you denied me." Abu Bakr knelt down and explained: "O Messenger of God, it was my fault!" 
Hakim al-Nisaburi divided them into twelve ranks, and most scholars accept his ranking:
• The four Rightly Guided Caliphs (Abu Bakr, 'Umar, 'Uthman, and 'Ali), and the rest of the ten who were promised Paradise while still alive (Zubayr ibn al-'Awwam, Abu 'Ubayda ibn al-Jarrah, 'Abd al-Rahman ibn 'Awf, Talha ibn 'Ubaydullah, Sa'd ibn Abi Waqqas, and Sa'id ibn Zayd).
• Those who believed prior to 'Umar's conversion and met secretly in Arqam's house to listen to the Messenger.
• Those who migrated to Abyssinia.
• The Helpers (Ansar) who swore their allegiance to the Messsenger at al-'Aqaba.
• The Helpers who swore their allegiance at al-'Aqaba the following year.
• The Emigrants who joined the Messenger during the hijra before his arrival in Madina from Quba, where he stayed for a short while.
• The Companions who fought at Badr.
• Those who emigrated to Madina between the Battle of Badr and the Treaty of Hudaybiya.
• The Companions who swore allegiance under a tree during the expedition of Hudaybiya.
• Those who converted and emigrated to Madina after the Treaty of Hudaybiya.
• Those who became Muslims after the conquest of Makka.
• Children who saw the Messenger any time or any place after the conquest of Makka.
Muslim scholars of the highest rank, whose minds are enlightened by scientific knowledge and whose souls are illumined by religious knowledge and practice, agree that Prophets are the greatest members of humanity. Immediately after them come the Companions of the Last Prophet, who is the greatest Prophet.
Although some Companions may have the same rank as previous Prophets in a particular virtue, no one can equal a Prophet in general terms. Likewise, some of the greatest saints or scholars can compete with the Companions or even excel some of them in particular virtues, but even a Companion of the lowest rank, such as Wahshi (the slayer of Hamza), is still greater, in general terms, than all who come after the Companions. All Muslim scholars, whether Traditionists, theologians, or saints, agree upon this.
 Ibn Athir, Usd al-Ghaba, 4:132.
 Bukhari, "Tafsir," 7/3.