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.

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

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