* Pemex selling nearly all of Repsol stake
* Share sale worth $3 billion
* Citigroup, Deutsche Bank joint bookrunners
(New throughout, adds details on Mexican energy market, Repsol shareholders)
MADRID, June 3 (Reuters) - Mexico's national oil company Pemex will sell a 7.86 percent stake in Spanish oil firm Repsol, worth about 2.2 billion euros ($3.0 billion), Citigroup and Deutsche Bank said on Tuesday.
The sale, to be made via an accelerated book build, should be completed by Wednesday, the banks said. It ends a long relationship between Pemex and Repsol that had run into trouble in recent years over disagreements on policies ranging from top management to the handling of Repsol's investments in Argentina.
Through this sale, Pemex will divest nearly all of its holding in Repsol, where its 9 percent stake has made it one of the top three shareholders.
Mexico's government had suggested a possible Repsol stake sale in recent weeks with a view to investing the funds in new opportunities in Mexico. The country is ending a state oil and gas monopoly that has existed since 1938.
Pemex, one of Repsol's oldest shareholders, had criticized the Spanish company publicly over Chairman Antonio Brufau's management, in part due to his handling of the Argentine government's move to nationalize Repsol's YPF unit. Pemex tried to oust Brufau in 2011.
The tension between the companies escalated, then reached a breaking point last month when Brufau appointed a chief executive officer whom Pemex had not backed. Pemex had long sought a CEO who would balance Brufau's executive power.
Mexican President Enrique Pena Nieto will make his first official visit to Spain on June 9-10.
As a result of the divestment, Pemex will lose its seat on Repsol's board. The companies had hoped to team up to explore for offshore oil in the Gulf of Mexico, so the sale represents a lost opportunity for both.
Both Repsol and Pemex declined to comment.
Still, Repsol shares could benefit in the short term, analysts said, as the sale erases uncertainty that had been holding back gains over past months, even as the company made a successful $6.3 billion exit from Argentina.
Repsol shares dipped on Tuesday to close at 20.865 euros before news of the sale. The shares remain up 13 percent so far this year. The company is due to pay a 1 euro-per-share special dividend on June 6 with part of the proceeds from its Argentine compensation.
Investors are watching to see if other major Repsol shareholders look to sell stakes. Some banking sources had pointed to Repsol as a takeover target.
GDF Suez and Galp have in the past looked at the possibility of acquiring Repsol but their interest never went very far, sources told Reuters, in part because of expected difficulty in gaining Spanish government approval.
Repsol itself is on the hunt for acquisitions to expand its exploration and production business, with a preference for oil assets that offer cash flow, banking sources said.
JP Morgan has already identified potential targets. Repsol is opening up to new ideas with a target range of between 2 billion and 6 billion euros, one banking source said. ($1 = 0.7342 Euros)
(Additional reporting by Anjuli Davies and Sophie Sassard and Ana Isabel Martinez in Mexico City; Editing by Jane Merriman and David Gregorio)