Competitiveness is desirable, neutral and undesirable in Islam. Basically, it depends on what the area of competition is:
- Competition over worldly matters is prohibited
- Competition over permissible acts is permitted
- Competition over good deeds (deposit of the Hereafter) is praised and commended.
In Sahih Muslim (and Muatta' Malik, and other books), the Prophet ﷺ told us not to compete with one another (the word used in Arabic is tanāfasu, which translates to "compete", rather than "feel envy" as in the translation below):
حَدَّثَنَا يَحْيَى بْنُ يَحْيَى، قَالَ قَرَأْتُ عَلَى مَالِكٍ عَنْ أَبِي الزِّنَادِ، عَنِ الأَعْرَجِ، عَنْ أَبِي هُرَيْرَةَ، أَنَّ رَسُولَ اللَّهِ صلى الله عليه وسلم قَالَ: إِيَّاكُمْ وَالظَّنَّ فَإِنَّ الظَّنَّ أَكْذَبُ الْحَدِيثِ وَلاَ تَحَسَّسُوا وَلاَ تَجَسَّسُوا وَلاَ تَنَافَسُوا وَلاَ تَحَاسَدُوا وَلاَ تَبَاغَضُوا وَلاَ تَدَابَرُوا وَكُونُوا عِبَادَ اللَّهِ إِخْوَانًا .
Abu Huraira reported Allah's Messenger (ﷺ) as saying: Avoid suspicion, for suspicion is the gravest lie in talk and do not be inquisitive about one another and do not spy upon one another and do not feel envy [compete] with the other, and nurse no malice, and nurse no aversion and hostility against one another. And be fellow-brothers and servants of Allah.
— Sahih Muslim, Book 45, Hadith 35
In At-Tamhīd (Arabic: التمهيد لما في الموطأ من المعاني والأسانيد), Vol. 18, pp. 22, Ibn 'Abdul-Barr (Arabic: أبو عمر يوسف بن عبد الله بن محمد بن عبد البر) commented on "do not compete" in this hadith saying that it is referring to competing in worldly matters where the objective is showing off or arrogance or seeking positions where one can control or transgress against people, or envy others over what Allah ﷻ has ordained to them in fortune. He then added that competing in good deeds and good manners dis not fall under this prohibition.
The Prophet ﷺ explained in another hadith the reasons for avoiding competing over worldly matters. At one stage, the Prophet ﷺ sent Abu 'Ubaida ibn Al-Jarrāh to the people of Bahrain (not the current country, but a place on the eastern tip of the Arabian peninsula) to collect jizyah. When he returned with the jizyah, the Prophet ﷺ saw in the prayer some faces of companions that did not normally frequent his masjid. During that time, there were already several masjids established in Medina. Those that the Prophet ﷺ noticed were from the northern part of Medina, and this is where they normally prayed. When the Prophet ﷺ finished the fajr prayer, he noticed that that group was lingering in front of him. He asked them if they had heard that Abu 'Ubaida had returned with the jizyah from Bahrain. When they affirmed, he smiled and said (the word used in Arabic is tanāfasuha, which translates to "compete for them [the worldly matters]", rather than "vie with one another" as in the translation below):
قَالَ رَسُولُ اللَّهِ صلى الله عليه وسلم: فَأَبْشِرُوا وَأَمِّلُوا مَا يَسُرُّكُمْ فَوَاللَّهِ مَا الْفَقْرَ أَخْشَى عَلَيْكُمْ . وَلَكِنِّي أَخْشَى عَلَيْكُمْ أَنْ تُبْسَطَ الدُّنْيَا عَلَيْكُمْ كَمَا بُسِطَتْ عَلَى مَنْ كَانَ قَبْلَكُمْ فَتَنَافَسُوهَا كَمَا تَنَافَسُوهَا وَتُهْلِكَكُمْ كَمَا أَهْلَكَتْهُمْ .
Allah's Messenger (ﷺ) said: "Be happy and be hopeful of that which gives you delight. By Allah, it is not the poverty about which I fear in regard to you but I am afraid in your case that (the worldly) riches may be given to you as were given to those who had gone before you and you begin to vie [compete] with one another for them as they vied [competed] for them, and these may destroy you as these destroyed them."
— Sahih Muslim, Book 55, Hadith 9
It is competing for worldly matters that could lead to the destruction of the Muslim nation as it had destroyed those before us.
On the other hand, competing for good deeds was common during the time of the Prophet ﷺ and his companions. In Fat'h Al-Bari (Arabic: فتح الباري شرح صحيح البخاري) by Ibn Hajar al-Asqalani (Arabic: أحمد بن علي بن حجر العسقلاني), in Vol. 1, pp. 167, said that competing in the obedience of Allah is to be commended, and competing in what is permissible is permitted, then he mentioned the following verse:
خِتَامُهُ مِسْكٌ ۚ وَفِي ذَٰلِكَ فَلْيَتَنَافَسِ الْمُتَنَافِسُونَ
The last of it is musk. So for this let the competitors compete.
— Surat Al-Mutaffifin 83:26
A form of competition in an area that is permitted is horse racing, where the Prophet ﷺ held such races (see Sahih Muslim 33/139). It is also known that the Prophet ﷺ raced with his wife 'A'isha when they first got married and she beat him. Then he challenged her again a few years later — she had put on some weight at that point — and he beat her. He told her that they were tied then (see Sunan Abi Dawud 15/102).
As for competing over good deeds, the examples are countless. One of them is the continuous rivalry between 'Umar ibn al-Khattāb and Abu Bakr. 'Umar always wanted to beat Abu Bakr in good deeds, but without much success. During the Prophet's last battle, when the Romans wanted to exterminate all Muslims, the Prophet ﷺ embarked on preparing an army for the 'Usra Expedition that was meant to meet the Romans in Tabūk. He asked the companions to donate money for the expedition. 'Umar was quite pleased as he had quite a large sum of money at the time. He decided to donate half his money to the expedition and was quite sure he would surpass Abu Bakr. However, as 'Umar narrated, he lost to Abu Bakr yet one more time:
دَّثَنَا أَحْمَدُ بْنُ صَالِحٍ، وَعُثْمَانُ بْنُ أَبِي شَيْبَةَ، - وَهَذَا حَدِيثُهُ - قَالاَ حَدَّثَنَا الْفَضْلُ بْنُ دُكَيْنٍ، حَدَّثَنَا هِشَامُ بْنُ سَعْدٍ، عَنْ زَيْدِ بْنِ أَسْلَمَ، عَنْ أَبِيهِ، قَالَ سَمِعْتُ عُمَرَ بْنَ الْخَطَّابِ، - رضى الله عنه - يَقُولُ أَمَرَنَا رَسُولُ اللَّهِ صلى الله عليه وسلم يَوْمًا أَنْ نَتَصَدَّقَ فَوَافَقَ ذَلِكَ مَالاً عِنْدِي فَقُلْتُ الْيَوْمَ أَسْبِقُ أَبَا بَكْرٍ إِنْ سَبَقْتُهُ يَوْمًا فَجِئْتُ بِنِصْفِ مَالِي فَقَالَ رَسُولُ اللَّهِ صلى الله عليه وسلم: مَا أَبْقَيْتَ لأَهْلِكَ . قُلْتُ مِثْلَهُ . قَالَ وَأَتَى أَبُو بَكْرٍ - رضى الله عنه - بِكُلِّ مَا عِنْدَهُ فَقَالَ لَهُ رَسُولُ اللَّهِ صلى الله عليه وسلم " مَا أَبْقَيْتَ لأَهْلِكَ . قَالَ أَبْقَيْتُ لَهُمُ اللَّهَ وَرَسُولَهُ . قُلْتُ لاَ أُسَابِقُكَ إِلَى شَىْءٍ أَبَدًا .
Narrated Umar ibn al-Khattab: The Messenger of Allah (ﷺ) commanded us one day to give sadaqah. At that time I had some property. I said: "Today I shall surpass Abu Bakr if I surpass him any day." I, therefore, brought half my property. The Messenger of Allah (ﷺ) asked: "What did you leave for your family?" I replied: "The same amount." Abu Bakr brought all that he had with him. The Messenger of Allah (ﷺ) asked him: "What did you leave for your family?" He replied: "I left Allah and His Apostle for them." I said: "I shall never compete you in anything."
— Sunan Abi Dawud, Book 9, Hadith 123