General Principle
Whatever raka'at you catch with the imam counts as the first part of your prayer. What you missed is completed after the imam gives the final salam.
Source: Sahih al-Bukhari, Sahih Muslim
Adhkar
How to replace the missed raka'ah when you arrive late to join with the Jama'ah.




Whatever raka'at you catch with the imam counts as the first part of your prayer. What you missed is completed after the imam gives the final salam.
Source: Sahih al-Bukhari, Sahih Muslim
If you make takbiratul-ihram and join the imam while he is still in ruku' before he rises, that raka'ah is counted for you.
Source: Abu Dawud 893
After the imam's salam, stand up and complete one raka'ah, reciting Al-Fatihah and another surah aloud, then perform tashahhud and salam.
After the imam's salam, stand and pray one raka'ah with Al-Fatihah and a short surah, sit for tashahhud, then give salam.
After the imam's salam, stand and pray two raka'at silently with Al-Fatihah and a short surah in each, then sit for the final tashahhud and salam.
After the imam's salam, stand and pray one raka'ah with Al-Fatihah and a short surah, sit for the first tashahhud, then stand and pray two more raka'at with only Al-Fatihah, then the final tashahhud and salam.
If you joined after the imam gave salam, pray the full salah on your own as you normally would.