Former President Barack Obama surprises students at McKinley Technology High School in Washington, D.C., on Friday.

Eric Schultz, an adviser to the former commander-in-chief, said Obama was there "to welcome back students as they start a new school year."

Students smiled and looked shocked at Obama's presence in a photo tweeted by Schultz.

@BarackObama made a surprise visit to McKinley Tech HS here in DC to welcome back students as they start a new school year. pic.twitter.com/Y64tAE0KBl — Eric Schultz (@EricSchultz) September 8, 2017

Obama wrote on Twitter that he was "proud" of the students.

"Inspiring young minds that make me hopeful about our future," he wrote.