If one, while expecting a baby, has the intention to name the child Muhammad or Ali, the child will be a boy with the permission of Allah (swt):

“Once ibn Ghaylan al-Mada’iniy and I visited abu al-Hassan, al-Rida’, ‘Alayhi al-Salam, and ibn Ghaylan said to him (the Imam), ‘I pray to Allah to keep you well, I have been informed that if one’s wife is pregnant and he keeps his intention to name him Muhammad a son then is born to him.’ He (the Imam) said, ‘If one’s wife is pregnant and he keeps in his intention to name him Ali, (in this case also) a son will born to him.’ He (the Imam) then said, ‘Ali and Muhammad is one thing.’ He then said, ‘I pray to Allah to keep you well, I left my wife pregnant, please pray to Allah to make him a boy.’ He (the Imam) bent down his head for a long time; then raised his head and said, ‘Name him Ali because it is good for his long life.’ We then entered Makkah and a letter came from al-Mada’in saying, “A boy is born to him.”’”

Sanad: It is narrated from the narrator of the previous Hadith from Muhammad ibn Ali from Ali ibn al-Hakam from al-Husayn ibn Sa‘id who has said the above hadith

Source: Furu’ al-Kafi, Volume 6, Chapter 5, Hadith #2 (See Image 1 below)

Grading: Allaamah al-Majlisi (rh) has graded it Sahih/Authentic [Mira’at al-Uqool, Volume 21, Page 20 (See Image 2 below)]

Untitled

Untitled

It is no wonder one of the most popular names in the world is Muhammad (see here); Salawat 🙂