Afghan women chant slogans to protest against the ban on university education for women, in Kabul on December 22, 2022. AFP
"Taliban policies designed to erase women from public life will have consequences for how our countries engage with the Taliban," the ministers of the club of rich nations said in a statement, after holding virtual talks.
Afghanistan's Taliban rulers, who promised a softer rule when they returned to power last year, have drawn global outrage with their announcement this week banning women from higher education.
The hardline Islamists had already barred girls from attending secondary schools in March.
Both decisions should be reversed "without delay", the G7 ministers said.
"Gender persecution may amount to a crime against humanity under the Rome Statute, to which Afghanistan is a state party," they said, in a reference to the International Criminal Court in The Hague.
"The G7 members stand with all Afghans in their demand to exercise their human rights consistent with Afghanistan's obligations under international law," they added.
German Foreign Minister Annalena Baerbock, whose country holds the G7 rotating presidency, called the university ban another step "towards the Stone Age".
"Women and girls in Afghanistan aren't just not allowed in universities anymore, they aren't allowed in parks, they aren't allowed to step outside the door unveiled, they aren't allowed to learn," she told a Berlin press conference.
"The Taliban are taking away everything that makes a life for women and girls in Afghanistan. And living is more than just surviving," she said.
The G7 consists of Britain, Canada, Italy, France, Germany, Japan and the United States.