Short answer
Yes, by Allah's grace. When Hakim ibn Hizam asked about the charity and kindness he did before Islam, the Prophet ﷺ told him: you accepted Islam along with the good you did before. Many scholars take this to mean a convert is rewarded for those deeds, while past sins are wiped away.
Acts of worship need Islam to be valid in law, so rites such as a Hajj performed before Islam do not count, and Hajj must be performed again if one is able. As for reward, many scholars, including al-Nawawi, explain the hadith of Hakim ibn Hizam to mean that Allah records the good a convert did before Islam.
The four schools agree on this.
Explanation
Hakim ibn Hizam, a nephew of Khadijah, was known in Makkah for generosity. He asked the Prophet ﷺ about the charity he had given, the slaves he had freed and the family ties he had kept before Islam: would he have any reward for them? The Prophet ﷺ answered: you accepted Islam along with the good that went before. Another hadith says that when a person accepts Islam and lives it well, Allah writes for him every good deed he did before.
Scholars discussed what this means. Some said it refers to the good character those deeds built in him. Many, including al-Nawawi, took it at face value: the good deeds are rewarded once the person becomes Muslim. The jurists' rule that worship from a non-Muslim is not valid is about legal effects in this world, not about Allah's generosity.
So a convert gains on both sides. Past sins are wiped out, since Islam erases what came before it, and those who repent and do good may even have their bad deeds replaced with good ones. Past good is kept.
- Charity you gave: no need to repeat it.
- Hajj or umrah performed before Islam: does not count; perform Hajj as a Muslim if you are able.
- Prayers and fasts missed before Islam: not made up. See making up missed worship.
See also are past sins forgiven.
The evidence
Quran, Surah Al-Furqaan 25:70
إِلَّا مَن تَابَ وَءَامَنَ وَعَمِلَ عَمَلًۭا صَٰلِحًۭا فَأُو۟لَٰٓئِكَ يُبَدِّلُ ٱللَّهُ سَيِّـَٔاتِهِمْ حَسَنَٰتٍۢ ۗ وَكَانَ ٱللَّهُ غَفُورًۭا رَّحِيمًۭا ﴿٧٠﴾
Except for those who repent, believe and do righteous work. For them Allah will replace their evil deeds with good. And ever is Allah Forgiving and Merciful.
Faith and repentance can turn past bad deeds into good.
Quran, Surah Al-Anfaal 8:38
قُل لِّلَّذِينَ كَفَرُوٓا۟ إِن يَنتَهُوا۟ يُغْفَرْ لَهُم مَّا قَدْ سَلَفَ وَإِن يَعُودُوا۟ فَقَدْ مَضَتْ سُنَّتُ ٱلْأَوَّلِينَ ﴿٣٨﴾
Say to those who have disbelieved [that] if they cease, what has previously occurred will be forgiven for them. But if they return [to hostility] - then the precedent of the former [rebellious] peoples has already taken place.
Accepting Islam wipes out past sins.
Sahih al-Bukhari 1436
Sahih... أسلمت على ما سلف من خير ...
"You accepted Islam along with the good you did before."
A convert keeps the reward of past good deeds.
Sunan an-Nasa'i 4998
Grading to be checked... كتب الله له كل حسنة كان أزلفها ...
"Allah writes for him every good deed he did before."
The good done before Islam is recorded.
Sahih Muslim 121
Sahih... أن الإسلام يهدم ما كان قبله ...
"Islam wipes out what came before it."
Past sins are forgiven.
Where the ruling is recorded
- Sharh Sahih Muslim (al-Nawawi), Kitab al-Iman, the chapter on the deeds of a disbeliever who later accepts Islam. Discusses the views on the hadith of Hakim ibn Hizam.
Checked by our team. For a more accurate answer to your own situation, consult a scholar. Quran translation by Sahih International. Hadith Arabic from the standard editions of the six books and the Muwatta, with gradings as recorded there; the English is our own rendering. Spotted a mistake? Tell us.