"These are the first steps towards a great alliance in the name of freedom," Italian Interior Minister Marco Minniti said after a two-day meeting with his Group of Seven counterparts, stressing the importance of the internet for extremist "recruitment, training and radicalisation."
Officials said the accord aimed at removing jihadist content from the Web within two hours of being posted.
"Our enemies are moving at the speed of a tweet and we need to counter them just as quickly," acting US Homeland Security Secretary Elaine Duke said.
While acknowledging progress had been made, Britain's Home Secretary Amber Rudd insisted "companies need to go further and faster to not only take down extremist content but also stop it being uploaded in the first place".
The meeting on the Italian island of Ischia off Naples also focused on ways to tackle one of the West's biggest security threats -- jihadist fighters fleeing Syria -- as the European Union promised to help close a migration route considered a potential back door for terrorists.
Tens of thousands of citizens from Western countries travelled to Syria and Iraq to fight for the Islamic State group between 2014 and 2016, including some who then returned home and staged attacks that claimed dozens of lives.
Minniti warned last week that fighters planning revenge attacks following the collapse of the IS stronghold in Raqa could hitch lifts back to Europe on migrant boats from Libya.
The United States and Italy signed an agreement on the sidelines of the G7 meeting to share their fingerprint databases in a bid to root out potential extremists posing as asylum seekers.
The "technical understanding" aims "to ascertain whether (migrants, asylum seekers or refugees) are noted criminal suspects or terrorists", Minniti's office said.
Earlier, EU President Donald Tusk promised the bloc would fork out more funds to help shut down the perilous crossing from Libya to Italy -- a popular path for migrants who hope to journey on to Europe.
The EU would offer "stronger support for Italy's work with the Libyan authorities", and there was "a real chance of closing the central Mediterranean route", he said.
Italy has played a major role in training Libya's coastguard to stop human trafficking in its territorial waters, as well as making controversial deals with Libyan militias to stop migrants from setting off.
Minniti said the G7 ministers had discussed how to go about "de-radicalising" citizens returning from the IS frontline, to prevent them becoming security risks in jails.
The ministers had also brainstormed on how to tackle the legal headache of prosecuting returnees, amid questions over what sort of evidence, collected by whom, could be used in a domestic court.
The US and Britain called for more to be done on aviation safety, particularly through the sharing of passenger data.
'Malware of terror'
The Group of Seven --- Britain, Canada, France, Germany, Italy, Japan and the US -- said it had also called on the Web giants to work with their smaller partners to bolster the anti-extremism shield.
"IS took to the technology world like a fish to water," Minniti said, adding that it was time to unleash the antidote to its "malware of terror".
Rudd said the UK government would do its part by changing the law so that those accessing and viewing extremist material on the web could face up to 15 years behind bars.
But Julian Richards, security specialist at BUCSIS (Buckingham University Centre for Security and Intelligence Studies), said the rest of the G7 was unlikely to get behind her on that front.
"The UK's fairly hard approach of introducing legislative measures to try to force companies to cooperate... and suggestions that people radicalising online should have longer sentences, are often considered rather unpalatable and too politically sensitive in many other advanced countries," he told AFP.