In The Name of Allaah, The Most Merciful The Bestower of Mercy.
Allaah [The Most High] stated that Yoosuf [alayhis salaam] said:
رَبِّ قَدۡ ءَاتَيۡتَنِى مِنَ ٱلۡمُلۡكِ وَعَلَّمۡتَنِى مِن تَأۡوِيلِ ٱلۡأَحَادِيثِۚ فَاطِرَ ٱلسَّمَـٰوَٲتِ وَٱلۡأَرۡضِ أَنتَ وَلِىِّۦ فِى ٱلدُّنۡيَا وَٱلۡأَخِرَةِۖ تَوَفَّنِى مُسۡلِمً۬ا وَأَلۡحِقۡنِى بِٱلصَّـٰلِحِينَ
My Lord! You have indeed bestowed on me of the sovereignty, and taught me the interpretation of dreams; The (only) Creator of the heavens and the earth! You are my Wali (Protector, Helper, Supporter, Guardian, etc.) in this world and in the Hereafter, cause me to die as a Muslim (the one submitting to Your Will), and join me with the righteous.” [Soorah Yoosuf: Ayah:101]
Regarding the statement: [أَنتَ وَلِيِّي فِي الدُّنْيَا وَالْآخِرَةِ ۖ تَوَفَّنِي مُسْلِمًا وَأَلْحِقْنِي بِالصَّالِحِينَ – You [Allaah] are my Wali [Protector, Helper, Supporter, Guardian, etc.] in this world and in the Hereafter, cause me to die as a Muslim, and join me with the righteous], Imaam Ibnul Qayyim [rahimahullaah] said: This supplication gathers within it a firm acknowledgement of Allaah’s Oneness [i.e Tawheed], submission to the Lord [Allaah], a manifestation of one’s need of Allaah, a declaration of one’s innocence from having a protector besides Allaah, [free is He from all imperfections], and that being enabled to die upon Islaam is the loftiest goal of the slave, and that it is [an affair] only in the hands of Allaah and not in the hands of the slave; an acknowledgement of the afterlife and seeking [to be included in the] company of those granted happiness and success. [An Excerpt from ‘Al-Fawaa’d. page 286. slightly paraphrased]