ALGIERS, Nov 22 (Reuters) - The Algerian state energy firm Sonatrach and Spain's Cepsa signed an agreement on Tuesday to extend partnership contracts for two oil fields in the North African country, Sonatrach said.

OPEC member Algeria has announced plans to boost oil and gas production after stagnation in recent years due to a lack of foreign investment.

Under Tuesday's deal, contracts for the Rhourde El Krouf (RKF) and Ourhoud oil fields will be extended by 25 years and 10 years respectively, Sonatrach said in a statement carried by the state news agency APS.

The Sonatrach-Cepsa contract for Ourhoud was due to expire in 2019, the statement said. The agreement was signed by Sonatrach chief Amine Mazouzi and Cepsa CEO Pedro Miro Roig.

The two sides also signed a memorandum of understanding "to explore opportunities in other areas where both companies have common interests in Algeria and internationally", the statement added.

Algeria says it expects gas output to reach 141.3 billion cubic metres (bcm) in 2017, 143.9 bcm in 2018, 150 bcm in 2019 and 165 bcm in 2020.

Oil production targets are 75 million tonnes of oil equivalent in 2017 and 2018, 77 million tonnes in 2019 and 82 million tonnes in 2020.

In 2015, gas production stood at 128.3 bcm, while oil output reached 67 million tonnes.

(Reporting by Hamid Ould Ahmed; Editing by Aidan Lewis and Kevin Liffey) ((hamid.ouldahmed@thomsonreuters.com;))