Mr Obama greeted the smiling youngsters of Mount Pleasant Primary School in Welsh saying "bore da" - "good morning" - and then listened to a welcome message, thanking him for being the first serving US president to visit Wales.
Watch President Obama and Prime Minister David Cameron greet the schoolchildren in Welsh below:
Primary school children were given a lesson they are unlikely to forget as Barack Obama and David Cameron dropped in to class.
The road along Ruskin Avenue, which is usually busy with parents dropping their youngsters off, was faced by the sight of scores of police officers and the presidential convoy pulling up at the school gates.
The president and Prime Minister were in Rogerstone, near Newport, ahead of the Nato summit at nearby Celtic Manor.
Youngsters were treated to a series of Nato-themed second day back at school.
Army reservist Lieutenant Rachel Broughton, 28, of Tenby, spoke to year five and six pupils about the summit and how Nato encourages co-operation between different nations.
Among the crowds gathered outside was college student Jay Singh, 16.
He said: "It's pretty surreal, Barack Obama being in Rogerstone. It's great that he's come here and shows Newport has plenty to offer and it's not just about Cardiff.
Earlier on, children had to go through a metal detector before starting their second day of the academic year.
When a smiling Mr Obama walked into a Year 6 class speaking Welsh, the pupils' nervous chatter turned to delighted smiles.
After listening to a question-and-answer session about Nato, Mr Obama and Mr Cameron were ushered into the school hall to inspect youngsters' artworks.
Sitting down at a low-level children's table, perched in front of a classroom display about adventurers such as US astronaut Neil Armstrong, they chatted with youngsters about their drawings of the summit venue, the Celtic Manor.