For three years, Rasulullah (sallallahu ‘alaihi wasallam) continued inviting people to Islam secretly and people gradually embraced Islam. After this period of three years, the following command was revealed, instructing Rasulullah (sallallahu ‘alaihi wasallam) to invite to Islam openly:
فَاصۡدَعۡ بِمَا تُؤۡمَرُ وَ اَعۡرِضۡ عَنِ الۡمُشۡرِکِیۡنَ ﴿۹۴﴾
Then proclaim openly that which you have been instructed (i.e. Islam) and turn away from the disbelievers (Surah Hijr v. 94)
وَ اَنۡذِرۡ عَشِیۡرَتَکَ الۡاَقۡرَبِیۡنَ ﴿۲۱۴﴾ۙ وَ اخۡفِضۡ جَنَاحَکَ لِمَنِ اتَّبَعَکَ مِنَ الۡمُؤۡمِنِیۡنَ ﴿۲۱۵﴾ۚ
And warn your close relatives and treat those believers who have followed you with affection and kindness (Surah Shu‘araa v. 214-215)
وَ قُلۡ اِنِّیۡۤ اَنَا النَّذِیۡرُ الۡمُبِیۡنُ ﴿ۚ۸۹﴾
And say (O Muhammed) I am indeed an open warner (Surah Hijr v. 89)
(Extracted from Seeratul Mustafa 1/171)