Praise be to Allah.
There are a number of views on this issue, one of which is that of Ibn Taymiyah (may Allah have mercy on him):
“A Prophet (Nabi) is one to whom Allah reveals (yanbi’uhu) something, and he passes on what Allah has reveals to him. If he is sent with that to those who go against the commandments of Allah, to convey a message from Allah to them, then he is a Messenger. But if he follows a sharee’ah that came before him, and is not himself sent to anyone to convey the message from Allah to them, then he is a Prophet and not a Messenger…”
(al-Nubuwwaat, p. 255). Other scholars add different details, but these are the most important of them.
And Allah knows best.