I asked Anas b. Malik about shortening of prayer. He said: When the Messenger of' Allah ﷺ had covered a distance of three miles or three farsakh (Shu'ba, one of the narrators, had some doubt about it) he observed two rak'ahs.
كَانَ رَسُولُ اللَّهِ ﷺ إِذَا خَرَجَ مَسِيرَةَ ثَلاَثَةِ أَمْيَالٍ أَوْ ثَلاَثَةِ فَرَاسِخَ شُعْبَةُ الشَّاكُّ صَلَّى رَكْعَتَيْنِ