Praise be to Allah.
The Quran was revealed by Allah, may He be glorified, as a law and a reference as to what is permissible and prohibited, what is commanded and forbidden, for people to follow, so that they obey its commands and abide by its prohibitions, take what it allows as permissible and take what it prohibits as forbidden. The Quran tells us about what happened before and what is yet to come, and it is a reference for judging between us. Allah says (interpretation of the meaning): “… We have neglected nothing in the Book…” [6:38].
After the Revelation was completed, Allah said (interpretation of the meaning): “… This day, I have perfected your religion for you…” [5:3].
The Sunnah [words and deeds of the Prophet (peace and blessings of Allah be upon him)] came to explain and complement the Quran. The Prophet (peace and blessings of Allah be upon him) said: “I have been given the Quran and something like it with it.” The phrase “something like it with it” refers to the Sunnah. (saheeh/authentic hadeeth).
Allah commanded us to refer to these two constitutional references, when He said (interpretation of the meaning): “…if you differ in anything amongst yourselves, refer it to Allah and His Messenger…” [4:59].
Referring to Allah means referring to the Quran, and referring to His Messenger means referring to the sunnah. The Quran is the primary source of legislation, then comes the sunnah.
And Allah knows best.