وَ إِنَّ مِنَ الشِّعْرِ لَحِکْمَةً وَاِنَّ مِنَ الْبَیَانِ لَسِحْرًا
Indeed, in poetry there is wisdom and in eloquence there is magic
The 19th of the 40 hadiths gathered by Shah Waliullah ad-Dehlawi in Shah Waliullah's Forty Hadith, given below in the original Arabic with an English translation and its reference.
وَ إِنَّ مِنَ الشِّعْرِ لَحِکْمَةً وَاِنَّ مِنَ الْبَیَانِ لَسِحْرًا
Indeed, in poetry there is wisdom and in eloquence there is magic
Text from the open hadith-api dataset. Hadith numbering follows that edition and can differ slightly from a printed copy — check the Arabic against a trusted mushaf of hadith before relying on a reference.