“It’s an honour to be with you,” Mr Trump told Mr Putin, who responded: “I’m delighted to meet you personally.”
Both sides listed a wide range of topics discussed, including Russia’s alleged meddling in the US election.
Climate change and trade are set to dominate the two-day G20 meeting.
Violent clashes between protesters and police have taken place in the streets outside the venue, with dozens left injured.
A huge police operation is trying to keep demonstrators – who are protesting against the presence of Mr Trump and Mr Putin, climate change and global wealth inequalities – well away from the summit venue, and water cannon have been deployed.
Earlier, US First Lady Melania Trump was unable to leave her hotel in Hamburg because of the protests.
The words were warm enough, but the body language was restrained as this meeting began. Neither man was smiling much as both said they hoped for positive results from their encounter. Their handshake, when it finally came, was brief and businesslike.
But they clearly had plenty to talk about, as their meeting went on well over the time allocated. Russia sees that alone as a success, proof that Vladimir Putin is a global leader to be reckoned with. No-one here is expecting any big deals though, like lifting sanctions for example.
The Kremlin has stressed all along that its main aim is to establish a “working dialogue” with Donald Trump, and perhaps begin the slow process of restoring relations with the US, which are at their lowest point in many years.
Canadian Prime Minister Justin Trudeau has urged G20 leaders to impress upon Mr Trump that he should act as a role model in addressing climate change.
“We’ll tell him it’s important to take a lead role in tackling climate change and creating good jobs,” he told German tabloid Bild, according to Reuters news agency.
Read more related