BERLIN, May 25 (Reuters) - Recent payments for Russian gas made in euros or dollars have worked, German government sources said on Wednesday, adding that the payments were in line with European Union rules.

Invoices for gas have become due in the past few days and Russia had said it wanted paying in roubles even though almost all contracts are denominated in euros or dollars. Exactly how the payments were executed remains unclear, however.

Companies reportedly continued to pay in euros or dollars, with the exchange into roubles via another account set up by the companies left to the Russian side.

The EU's executive told member states last week they could keep buying Russian gas without breaching sanctions imposed on Moscow following its invasion of Ukraine.

The Commission advised companies against opening a bank account in roubles at Gazprombank to do this, as requested by the Kremlin, but has not explicitly said doing so would breach sanctions in formal written guidance to governments.

A spokesperson for the German Economy Ministry, contacted by Reuters, said: "The contracts apply and must be adhered to. They are denominated in euros and dollars. So they are to be fulfilled in euros or dollars." (Reporting by Markus Wacket Writing by Paul Carrel Editing by Miranda Murray)