The class discussed the inspiration behind Mr. Lamar’s albums and his perception as an author himself. Mr. Lamar signed students’ artwork along the classroom walls and took selfies with beaming students.

“When I talk to kids, I’m really listening,” he said. “When I do that, we have a little bit of a bigger connection than me being Kendrick Lamar and you being a student. It’s almost like we’re friends. Because a friend listens.”

The class joined the rest of the student body, about 650 in total, in the school’s field house. Mr. Lamar sat on a panel with Chris Emdin, Mr. Mooney’s mentor from Teachers College and creator of the #hiphoped movement; Jamilia Lyiscott, who recently received a Ph.D. from Teachers College; Mr. Mooney; and some High Tech alumni to critique performances by the students.

Sade Ford, an 18-year-old senior, took the stage with her performance titled “It Takes a Village to Raise a Butterfly.” She touched upon leaving behind her hometown, Jersey City, and her coming journey as a first-generation college student at Rutgers University.

“The best part is the effect that she can give her perspective from different walks of life,” Mr. Lamar commented.

Another senior, Benjamin Vock, 17, created his poem within a day, inspired by Mr. Lamar’s song “Mortal Man.” He bemoaned the pain the black community felt with the deaths of young black men such as Michael Brown and Trayvon Martin and the privilege he experienced growing up white.

“That’s dope,” Mr. Lamar said. “You identify with my community and what’s going on in the world. And I appreciate you for that.”