Caution: Translations of Quran and Ḥadīth may lead to possible misapplications and misinterpretations. This site is intended for students of sacred knowledge that are proficient in comprehending classical Arabic and have a strong foundation in Islamic sciences. Also note that religious injunctions rely on several aspects beyond what one may glean through reading individual aḥādīth.
bukhari:3935Musaddad > Yazīd b. Zurayʿ > Maʿmar > al-Zuhrī > ʿUrwah > ʿĀʾishah

Originally, two rakʿat were prescribed in every prayer. When the Prophet ﷺ migrated (to Medina) four rakʿat were enjoined, while the journey prayer remained unchanged(i.e. two rakʿat).  

البخاري:٣٩٣٥حَدَّثَنَا مُسَدَّدٌ حَدَّثَنَا يَزِيدُ بْنُ زُرَيْعٍ حَدَّثَنَا مَعْمَرٌ عَنِ الزُّهْرِيِّ عَنْ عُرْوَةَ عَنْ عَائِشَةَ ؓ قَالَتْ

فُرِضَتِ الصَّلاَةُ رَكْعَتَيْنِ ثُمَّ هَاجَرَ النَّبِيُّ ﷺ فَفُرِضَتْ أَرْبَعًا وَتُرِكَتْ صَلاَةُ السَّفَرِ عَلَى الأُولَى  

تَابَعَهُ عَبْدُ الرَّزَّاقِ عَنْ مَعْمَرٍ

See similar narrations below:

Collected by Nasāʾī, Nasāʾī's Kubrá
nasai:1441Muḥammad b. Wahb > Muḥammad b. Salamah > Abū ʿAbd al-Raḥīm > Zayd > Ayyūb Wahū Ibn ʿĀʾidh > Bukayr b. al-Akhnas > Mujāhid Abū al-Ḥajjāj > Ibn ʿAbbās

"The prayer of the resident was enjoined on the tongue of your Prophet ﷺ, four (rak'ahs), and the prayer of the traveler is two rak'ahs, and the prayer of fear is one rak'ah."  

النسائي:١٤٤١أَخْبَرَنِي مُحَمَّدُ بْنُ وَهْبٍ قَالَ حَدَّثَنِي مُحَمَّدُ بْنُ سَلَمَةَ قَالَ حَدَّثَنِي أَبُو عَبْدِ الرَّحِيمِ قَالَ حَدَّثَنِي زَيْدٌ عَنْ أَيُّوبَ وَهُوَ ابْنُ عَائِذٍ عَنْ بُكَيْرِ بْنِ الأَخْنَسِ عَنْ مُجَاهِدٍ أَبِي الْحَجَّاجِ عَنِ ابْنِ عَبَّاسٍ قَالَ

فُرِضَتْ صَلاَةُ الْحَضَرِ عَلَى لِسَانِ نَبِيِّكُمْ ﷺ أَرْبَعًا وَصَلاَةُ السَّفَرِ رَكْعَتَيْنِ وَصَلاَةُ الْخَوْفِ رَكْعَةً  

nasai-kubra:523Muḥammad b. Wahb > Muḥammad b. Salamah > Abū ʿAbd al-Raḥīm Wahū Khālid b. Abū Yazīd > Zayd > Ayyūb > Bukayr b. al-Akhnas > Mujāhid > Ibn ʿAbbās

"The prayer of the resident was enjoined on the tongue of your Prophet ﷺ, four (rak'ahs), and the prayer of the traveler is two rak'ahs, and the prayer of fear is one rak'ah." (Using translation from Nasāʾī 1441)  

الكبرى للنسائي:٥٢٣أَخْبَرَنِي مُحَمَّدُ بْنُ وَهْبٍ قَالَ حَدَّثَنَا مُحَمَّدُ بْنُ سَلَمَةَ قَالَ حَدَّثَنِي أَبُو عَبْدِ الرَّحِيمِ وَهُوَ خَالِدُ بْنُ أَبِي يَزِيدَ قَالَ حَدَّثَنِي زَيْدٌ عَنْ أَيُّوبَ عَنْ بُكَيْرِ بْنِ الْأَخْنَسِ عَنْ مُجَاهِدٍ عَنِ ابْنِ عَبَّاسٍ قَالَ

«فُرِضَتْ صَلَاةُ الْحَضَرِ عَلَى لِسَانِ نَبِيِّكُمْ أَرْبَعًا وَصَلَاةُ السَّفَرِ رَكْعَتَيْنِ وَصَلَاةُ الْخَوْفِ رَكْعَةً»  

nasai-kubra:1912Muḥammad b. Wahb > Muḥammad b. Salamah > Abū ʿAbd al-Raḥīm > Zayd > Ayyūb > Bukayr b. al-Akhnas > Mujāhid Abū al-Ḥajjāj > Ibn ʿAbbās

"The prayer of the resident was enjoined on the tongue of your Prophet ﷺ, four (rak'ahs), and the prayer of the traveler is two rak'ahs, and the prayer of fear is one rak'ah." (Using translation from Nasāʾī 1441)  

الكبرى للنسائي:١٩١٢أَخْبَرَنِي مُحَمَّدُ بْنُ وَهْبٍ قَالَ حَدَّثَنَا مُحَمَّدُ بْنُ سَلَمَةَ قَالَ حَدَّثَنِي أَبُو عَبْدِ الرَّحِيمِ قَالَ حَدَّثَنِي زَيْدٌ عَنْ أَيُّوبَ عَنْ بُكَيْرِ بْنِ الْأَخْنَسِ عَنْ مُجَاهِدٍ أَبِي الْحَجَّاجِ عَنِ ابْنِ عَبَّاسٍ قَالَ

«فُرِضَتْ صَلَاةُ الْحَضَرِ عَلَى لِسَانِ نَبِيِّكُمْ ﷺ أَرْبَعًا وَصَلَاةُ السَّفَرِ رَكْعَتَيْنِ وَصَلَاةُ الْخَوْفِ رَكْعَةً»