WARSAW, May 24 (Reuters) - Pipeline operators in Poland and Russia agreed on a solution that will allow Kazakh oil transit to Germany to continue, removing a risk that it would stop in June, sources familiar with the matter told Reuters.

Transneft warned Kazakhstan in April that its oil transit to Germany could stop due to an impasse in certifying oil flow meters in Poland, required by June 5.

Polish state-owned pipeline operator PERN had concerns it could breach Western sanctions against Russia, Polish sources familiar with the situation said earlier this year.

PERN, Russia's state-controlled Transneft and Germany's PCK Schwedt refinery agreed that a non-Russian company will service the oil flow meters on the Polish part of the Druzhba pipeline, sources in Poland, Germany and Russia said.

A Slovak company will provide metering servicing for the Polish portion, removing the sanctions exposure to PERN. The meters need to be certified periodically to meet Russian standards.

Transneft's warning to Kazakhstan was a reminder of the landlocked country's reliance on Russia for its exports, with most of Kazakhstan's flow of 1.5 million barrels per day, or 1.5% of global supply, going via various Russian pipelines.

Transneft operates the Druzhba oil pipeline, one of the world's largest, capable of carrying 2 million barrels per day. Flows through Druzhba have dropped sharply since Russia's invasion of Ukraine as the European Union refused to buy Russian oil.

The northern leg of the Druzhba system, linking Germany via Poland and Belarus, is now used for Kazakhstan’s KEBCO oil exports for the Schwedt refinery, which supplies most of Berlin's fuel.

While the flow is relatively small, expected at 1.2 million metric tons of oil this year, it has helped Germany to not rely on Russian oil, a pledge Berlin made in 2022 following Russia's invasion of Ukraine.

Kazakhstan has extended the contract to supply the Schwedt refinery until the end of the year, the Kazakh state oil company KazMunayGaz said on Tuesday.

A PERN spokeswoman said the company was working with contractors to find a solution that will be in line with the existing laws.

Kazakhstan pipeline operator Kaztransoil said that currently there are no limitations for shipping Kazakh crude oil to Adamowo base on the Polish section of the pipeline near Belarussian border.

The Energy Ministry of Kazakhstan said in a written response to Reuters that "Kazakhstan and Russian parties have agreed to ship via Transneft and Druzhba trunk systems 1.2 mln tons of crude from Kazakhstan to Schwedt refinery."

Transneft did not immediately respond to a request for comment.

Germany's economy ministry declined to comment on company matters. A majority stake in the refinery has been under German government trusteeship since September 2022. (Reporting by Marek Strzelecki and Riham Alkousaa, Editing by Louise Heavens)