Stormzy will appear in the BBC's adaptation of Malorie Blackman's novel Noughts + Crosses.
The grime MC says it's a "dream come true" to be involved.
He will play newspaper editor Kolawale - a new character created for the show, which is currently being filmed in South Africa.
The 2001 book is set in a world divided by race, where black people ("Crosses") are the rulers and white people ("Noughts") are the underclass.
The story focuses on two young people in love: Sephy, who is a Cross, and Callum, a Nought.
It was a big success among young adults when it came out, and won multiple book awards.
It's the first of a series of four books, with a fifth to come out this summer.
Stormzy says he's "a diehard fan" of his "childhood hero" Malorie Blackman's novels, and he called Noughts + Crosses an "important show".
His role will be as a guest star in one episode of the six-part series.
The 25-year-old rapper will perform at Radio 1's Big Weekend in Middlesbrough in May and Glastonbury in June.
He's teased new music, telling Radio 1 Newsbeat in November that he's been "locked in the studio".
The Croydon-born artist released his own book last year, co-authored with Jude Yawson - who he got in touch with back in 2014 after reading something Jude had written about him online.
He's also partnered with the publisher Penguin Random House to create #Merky Books, which aims to help young writers become published authors.
Malorie Blackman spoke at the launch of #Merky Books last year, alongside the likes of rapper Akala and poet Benjamin Zephaniah.
She mostly writes stories for young adults and children, including Pig Heart Boy and Thief.
She's also written for the latest series of Doctor Who.