No one from the European Commission, the EU executive, was available for immediate comment on the deal, which ends months of talks on OPAL, which runs from the offshore section of Nord Stream through Germany to the Czech border (see background).
A deal could help to ease tensions between Russia and the EU, although the bigger issue of the European Commission's competition investigation into Gazprom remains unresolved.
"The ministry and the EU have reached an agreement on the OPAL pipeline. The agreement is to the satisfaction of both sides. They aim to sign the deal by the end of October," a Russian spokeswoman said.
Two EU sources, speaking on condition of anonymity, said a working party meeting had reached a political deal, which still needed legal endorsement.
Neither the Russian ministry nor the EU sources disclosed details and would not say whether Russia was getting the full access to the pipeline that it had been demanding.
Relations between Russia and the EU have been soured by Brussels' efforts to introduce more competition to the energy market and reduce Russian dominance of the bloc's gas supplies.
Gazprom's access to the 470-kilometre OPAL pipeline has been limited because of the EU's Third Energy Package legislation, which aims to prevent firms that already dominate supply from also controlling distribution networks.