These verses are attributed to Sayyiduna Ĥassān ibn Thābit al- Anşāri rađiyAllāhu ánhu :

agharru álayhi li’n nubuwwati khātamun
minallāhi mash-hūdun yalūĥu wa yush-hadu
wa đamma’l ilāh isma’n nabiyyi ila’smihi
idhā qāla fi’l khamsi’l mu-adh’dhinu ash-hadu

wa shaqqa lahu mini’smihi li yujilallahu
fa dhu’l árshi maĥmūdun wa hādha muĥammadu
nabiyyun atāna baáda ya’sin wa fatratin
mina’r rusuli wa’l awthānu fi’l arđi túbadu

fa amsā sirājan mustanīran wa hādiyan
yalūĥu kamā lāĥa’s şaqīlu’l muhannadu
wa andharanā nāran wa bash’shara jannatan
wa államana’l islāma fallāha naĥmadu

wa anta ilāhu’l khalqi rabbī wa khāliqī
bi dhālika mā ámmartu fi’n nāsi ash-hadu
táālayta rabba’n nāsi án qawli man dáā
siwāka ilāhan, anta aálā wa amjadu

laka’l khalqu wa’n náamā-u wa’l amru kulluhu
fa iyyaka nas-tahdī wa iyyāka nábudu

[Dīwān Ĥassān ibn Thābit al-Anşāri, pg.49]

—————

another version:

shaqqa lahu min ismihi kay yujillahu
fa dhu’l árshi maĥmūdun wa hādha muĥammadu
nabiyyun atāna baáda ya’sin wa fatratin
mina’r rusuli wa’l awthānu fi’l arđi túbadu

fa amsā sirājan mustanīran wa hādiyan
yalūĥu kamā lāĥa’s şaqīlu’l muhannadu
wa andharanā nāran wa bash’shara jannatan
wa államana’l islāma fAllāha naĥmadu

wa anta ilāhu’l ĥaqqi rabbī wa khāliqī
bi dhālika mā úmmirtu fi’n nāsi ash-hadu
táālayta rabba’n nāsi án qawli man dáā
siwāka ilāhan, anta aálā wa amjadu

laka’l khalqu wa’n náamā-u wa’l amru kulluhu
fa iyyaka nas-tahdī wa iyyāka nábudu
li anna thawāballāhi kulla muwaĥĥidin
jinānun mina’l firdawsi fīhā yukhalladu

[Dīwān Ĥassān ibn Thābit al-Anşāri, pg.84-85]