BERLIN (Reuters) - Saudi Arabia confirmed on Monday it was helping German investigators track Islamic State militants behind attacks in Germany and said one had been in contact with someone using a Saudi-registered mobile phone.

In a rare comment on its security operations, Riyadh confirmed that Saudi and German security experts had met and exchanged information on the contact made via social media, but the Middle Eastern contact was not located in Saudi Arabia.

A statement by the Saudi Arabian embassy, citing Interior Minister General Mansour al-Turki, did not specify which of two violent Islamist attacks last month this referred to.

One was an ax attack on a train near Wurzburg that wounded five people and another was a bomb in Ansbach in southern Germany that caused 15 injuries.

“The investigation found that the Islamic State contact person was not in Saudi Arabia but rather was in contact from the IS area,” the statement said, referring to the area in Syria and Iraq controlled by the militant Islamic State group.

The statement said the attacker in the other incident had no connection whatsoever with Saudi Arabia.

Al-Turki had said earlier that Saudi and German security experts had examined evidence showing that one of the attackers in Germany had been in contact through social media with a member of Islamic State using a Saudi phone number.

Turki said the suspect was in an unspecified “country of conflict” and declined to say whether he was a Saudi citizen.

“The investigation is still ongoing between experts in both countries to try to find the parties to the case,” Turki told Reuters in response to a question on a report by news magazine Der Spiegel.

Saudi Arabia, which says it is always ready to work with foreign countries to fight terrorism, rarely speaks publicly on specific cases.

Islamic State has claimed responsibility for an attack in Bavaria in which a 17-year-old refugee wounded five people with an ax before police shot him dead, and for a bombing in Ansbach, southern Germany, which wounded 15 people.

The 27-year-old Syrian, who carried out the Ansbach attack, had pledged allegiance to Islamic State on a video found on his phone, investigators said.

Der Spiegel said traces of the chat indicate that both men had been influenced by, and taken instructions from, unidentified people before the attacks.

German foreign ministry spokeswoman Sawsan Chebli told a news conference on Monday that Saudi Arabia had offered to help Germany investigate attacks in Germany claimed by Islamic State.

“Germany and other western countries have been successfully working together with Saudi Arabia on fighting terrorism for a long time,” she said. Information passed on by Saudi Arabia had been key in helping prevent terrorist attacks in Germany in the past, she said.

German interior ministry spokesman Tobias Plate said the government welcomed Saudi Arabia’s offer and added that cooperation with the security authorities there was of “significant value”. He declined to comment on the status of investigations.