HAMBURG, Germany — President Trump opened his meeting with Russian President Vladimir Putin with repeated questions about Russia's interference in the 2016 presidential election, and the two leaders agreed to work toward an agreement not to meddle in each other's elections in the future, officials from both sides said Friday.

Trump's apparent aggressiveness on the issue was stunning given the reluctance of both Trump and Putin to acknowledge Russia's use of hacking and propaganda to influence the U.S. vote last year.

"They had a very robust and lengthy exchange on the subject," said Secretary of State Rex Tillerson, who was in the room. "The two leaders agreed, though, that this is a substantial hindrance in the ability of us to move the Russian-U.S. relationship forward."

The two sides directed their governments to work out details of the agreement not to use cyberattacks as a tool of political subversion. One issue: How the two sides would monitor compliance. "How do we create a framework in which we have some ability to judge what is happening in the cyber world and who we can hold accountable?" Tillerson said.

The agreement, which came after a marathon two-hour meeting, was especially surprising considering Trump has cast doubt on the conclusions by U.S. intelligence agencies that Putin orchestrated the campaign as part of a high-level effort to get Trump elected president.

As multiple investigations into possible collusion between Russia and Trump campaign associates continue to shadow his presidency at home, Trump said as recently as Thursday in Warsaw that "nobody really knows" the extent of Russia's involvement.

Putin has also consistently denied interference and — as is typical of Russian disputations — demanded evidence. And Russian Foreign Minister Sergei Lavrov — who with Tillerson and two interpreters was one of the six people in the room — said Trump told Putin he "accepts" Putins denials.

But Tillerson suggested there was no such acceptance. "There was not a lot of re-litigating of the past. I think both of the leaders feel like there's a lot of things in the past that both of us are unhappy about. We're unhappy, they're unhappy," he said. "We simply have to find a way to go forward."

The meeting — the first face-to-face encounter between the two presidents as world leaders gathered in Hamburg for the Group of 20 summit Friday — also covered crises in North Korea and Ukraine and cemented a Syrian cease-fire agreement. The agreement between the United States and Russia is intended to quell fighting in southwest Syria and allow anti-government rebels there to focus on the Islamic State.

Russia supports the government of Syrian President Bashad al-Assad's government.

Except for two translators, Tillerson and Lavrov were the only other people in the room for the meeting, which was supposed to last 30 minutes but instead clocked in at two hours and 16 minutes. "There was just such a level of engagement and exchange, and neither one of them wanted to stop," Tillerson said.

Such was the chemistry between Trump and Putin that U.S. officials tried to wrap it up by sending first lady Melania Trump into the room to break it up.

"That didn't work, either," Tillerson said. The meeting went on another hour after that.

Indeed, the highly anticipated face-to-face meeting provided the world with its first visual clues about how the personalities of two powerful presidents would shape the relationship between the United States and Russia.

In a meeting room at the G-20 summit of world leaders, the two men appeared comfortable but formal, sitting forward in low-backed armchairs. Before their meeting, they leaned in closer to have a private word, and then farther apart to size each other up.

"We look forward to a lot of very positive things happening for Russia and for the United States and for everyone concerned," Trump said, striking an optimistic tone at the beginning of the meeting.

Putin said the two had spoken over the phone several times, "but phone conversations are never enough definitely." To address important international issues, "that will really need personal meetings," he said.

Before sitting down for their separate meeting, Trump and Putin attended group meetings of the summit where they sat three seats away from each other.

The Trump-Putin encounter is perhaps the most closely watched event of the summit, which has drawn thousands of protesters. On Saturday, Trump has separate meetings scheduled with at least five more world leaders, including Chinese President Xi Jinping, U.K. Prime Minister Theresa May, Indonesian President Joko Widodo and Singapore Prime Minister Lee Hsien Loong and Japanese Prime Minister Shinzo Abe.

Anti-globalization activists in Germany's second largest city set dozens of cars ablaze and tried to block leaders’ delegations, including first lady Melania Trump, from entering the grounds of the summit. Overnight, dozens of police were injured.

Washington Congressman Adam Smith weighs in on meeting and U.S.-Russia relations

Rep. Adam Smith, D-Washington, ranking member of the House Armed Services Committee expressed skepticism that the Syrian cease-fire agreement would last, or that President Donald Trump would take a hard enough line against Russian aggression during his first meeting with Vladimir Putin.

"I don’t disagree with the basic premise that the world would be a better place if Russia and the U.S. could find things to work together on and get along. That’s what we all hoped would come out of the Cold War, that Russia would integrate into the West; they would integrate into the community of nations trying to solve the problems that we faced, but that is not what Putin is doing. What Putin is doing is he’s trying to undermine democracy, every place he can," Smith said on Friday.

Smith points to evidence of meddling in elections, as well as interference in Ukraine and Syria as examples of Putin's strategy.

"Putin is going to push as far as he can push," said Smith. "Until he thinks cost is too high, he’s going to keep doing it."

However, there's long been a desire by administrations past and present to try and improve relations with Russia. Smith says he doesn't see the dynamic changing under Putin's leadership.

"Putin made a decision somewhere around 2007, 2008 that he didn’t want to work with the West. He perceived it in his best interest to set Russia up as a counterpoint to the West, in what to him was a zero-sum game, what’s good for them is bad for me and visa versa," said Smith.

"It's him against the West. To the extent he does deals with us, it’s to manipulate us to advance his own interests," continued Smith. "In the meantime, we have to try and keep the peace; we have to try to keep the lines of communication open, make sure what ever conflicts we may have in different places don’t blow up in a full scale war. So, I think communication is very important, even looking for places to work together is very important, but again it is also important to push back against Russian aggression, lest Putin think he can continue to do it with impunity."

Contributing: Kim Hjelmgaard from London