BRUSSELS, May 23 (Reuters) - The European Commission is continuing talks with Germany over a gas tariff Brussels and other countries have said undermines Europe's energy market, the Commission said on Thursday.

Germany's gas levy, which charges its neighbours an extra fee for buying gas from its storage, has faced criticism from some EU countries, who say it hurts their efforts to quit Russian gas - by making it more expensive to buy non-Russian gas delivered via Germany.

The Commission had prepared legal action against Germany last month over the issue, sources familiar with the matter told Reuters.

A Commission spokesperson did not comment on the potential legal action but said, for now, talks with the German government were continuing.

"The Commission has encouraged Germany to introduce a solution that removes these obstacles and does not hinder member states' efforts to diversify away from Russian gas," the spokesperson told a regular news conference.

Germany's economy and climate ministry did not immediately respond to a request for comment.

The ministry has previously said the levy was nondiscriminatory and other EU countries had benefited from Germany rapidly filling its vast gas storage.

EU energy commissioner Kadri Simson has written to German Economy and Climate Minister Robert Habeck, urging Berlin to address the issue, the spokesperson said.

Simson has previously said Germany's levy put the bloc's solidarity at risk and undermines the EU's gas market. EU single market rules forbid tariffs on trade between member countries.

The German tariff is a legacy of the European energy crisis that peaked in 2022 after Moscow slashed gas flows to Europe.

To recoup the billions of euros it spent on buying non-Russian gas at elevated prices to fill its storage caverns - the biggest of any country in the EU - Germany introduced what it termed a "neutrality charge" on gas sales to its neighbours.

The Czech Republic, Austria, Slovakia and Hungary have been pushing the Commission to take action against the German levy. (Reporting by Kate Abnett; additional reporting by Vera Eckert, Editing by William Maclean)