By Andrea Shalal

BERLIN (Reuters) - German Foreign Minster Frank-Walter Steinmeier on Wednesday called for greater cooperation between police and intelligence agencies in Europe as well as sustained international efforts to fight Islamic State after recent extremist attacks.

"The attacks of the past have shown us there is no absolute security," Steinmeier told Reuters in a written interview. "Terror strikes randomly and can hit each of us individually."

"The fact is we urgently need even closer cooperation between police and intelligence agencies in Europe, and better information sharing," he said. It was also critical to continue battling Islamic State and help improve the outlook for people in areas freed from the extremist group's influence.

Steinmeier's comments came a day after a 17-year-old Afghan refugee injured five people in southern Germany before being shot dead by police, the latest in a string of attacks for which Islamic State has claimed responsibility.

The German foreign minister said the only long-term way to combat extremism was to create conditions that allowed different religious and societal groups to live together peacefully, both in the West and in conflicted regions of the Middle East.

Steinmeier, who heads to Washington on Wednesday for meetings with other foreign and defense ministers to take stock of the fight against Islamic State, said the cooperation of Muslim communities was vital, citing their own interest in preventing young people from joining extremist groups.

He said the Iraqi military, backed by a U.S.-led coalition, was making gains week after week, including its recapture of Falluja, an Islamic State stronghold just west of Baghdad, last month, but it was critical that people in those areas could return to their cities and villages as quickly as possible.

Germany, already providing more humanitarian and stabilization aid than any other country according to Steinmeier, would offer another 10 million euros to prepare deal with the immense challenges facing Iraq after its forces retake Mosul, he said.

The Islamist militants have been broadly retreating since December, when the Iraqi army recaptured Ramadi, the largest city in the western region.

But U.S. and European officials say the military gains are not enough, and more must be done to support Iraq. Iraq is plagued by political infighting, corruption, and a growing fiscal crisis, as well as the Shi'ite Muslim-led government's efforts to reconcile with aggrieved minority Sunnis, who provide the bedrock of support for Islamic State.

"When the city of Mosul is freed from Islamic State, we will face enormous humanitarian, societal and political challenges, just as we saw when Falluja was liberated," Steinmeier told Reuters.

"We cannot lose the momentum of our efforts to stabilize Iraq now," he said, underscoring Germany's determination to dedicate more humanitarian funding to Iraq.

He said Germany, one of the co-hosts of an Iraqi donor conference aimed at raising $2 billion, would press hard to ensure sufficient funding to make the effort a full success.

(Reporting by Andrea Shalal, editing by G Crosse)