ALGIERS/MADRID (Reuters) - Algeria will cancel its deliveries of gas to Naturgy if the Spanish firm's shares are sold to another company, a source familiar with the matter told Reuters.

The source did not name the firm that could buy Naturgy shares, but Abu Dhabi's TAQA said last month it was in discussions with Naturgy's three largest shareholders which could lead to a possible full takeover bid for the largest natural gas firm in Spain.

Naturgy has a stake in a key gas pipeline between Spain and Algeria, as well as key contracts with Algeria's Sonatrach, which supplies gas to Spain through a pipeline. Naturgy also has a long-term contract to import some 3 billion cubic metres (bcm) of Russian liquefied natural gas every year.

"Naturgy has signed take or pay supply contracts until 2032 with Algeria," a company spokesperson told Reuters.

"Naturgy is not part of any negotiation on the company's shareholding, as was made clear in the relevant facts published at the time."

A spokesperson for Spain's energy ministry declined to comment.

TAQA said last month it was in talks with private equity firms CVC and GIP, each owning more than 20% of Naturgy, to buy their stakes.

TAQA also said it was talking to Naturgy's largest shareholder, Criteria, which owns a 26.7% stake about a possible partnership agreement.

Algeria was Spain's largest gas supplier in the first three months of the year, according to data from Spanish gas grid operator Enagas. It made up roughly a third of total gas imports. The bulk of such supplies comes through pipeline.

(Reporting by Lamine Chikhi, Joan Faus and Pietro Lombardi, editing by Deepa Babington)