By Tommy Wilkes and Nigam Prusty

NEW DELHI (Reuters) - India signed a deal to buy 36 Rafale fighter jets from France on Friday for around $8.7 billion, the country's first major acquisition of combat planes in two decades and a boost for Prime Minister Narendra Modi's plan to rebuild an ageing fleet.

The air force is down to 33 squadrons, against its requirement of 45 to face both China, with which it has a festering border dispute, and nuclear-armed rival Pakistan.

French Defence Minister Jean-Yves Le Drian signed the agreement with his Indian counterpart, Manohar Parrikar, in New Delhi, ending almost 18 months of wrangling over terms between New Delhi and manufacturer Dassault Aviation.

Parrikar said the deal, which a defense ministry official said was valued at 7.8 billion euros ($8.7 billion), would "significantly improve India's strike and defense capabilities".

Air force officials have warned for years of a major capability gap opening up with China and Pakistan without new state-of-the-art planes, as India's outdated and largely Russian-made fleet retires and production of a locally made plane was delayed.

India had originally awarded Dassault with an order for 126 Rafales in 2012 after the twin-engine fourth-generation fighter beat rivals in a decade-long selection process, but subsequent talks collapsed.

Modi, who has vowed to modernize India's armed forces with a $150 billion spending spree, personally intervened in April 2015 to agree on the smaller order of 36 and give the air force a near-term boost as he weighed options for a more fundamental overhaul.

The first ready-to-fly Rafales are expected to arrive by 2019 and India is set to have all 36 within six years.

Defence analyst Nitin Gokhale told Reuters that the price tag was fair and that India had negotiated it down from 12 billion euros.

Dassault said in a statement it welcomed the contract signing.

India says its locally made Tejas fighter, which took to the skies in July 33 years after it was cleared for development, will form a major part of its future fleet, but Parrikar has also said that India needed 100 new light combat aircraft by 2020 to replace Russian MiG-21s.

That has encouraged the likes of Sweden's Saab and U.S. Lockheed Martin to re-pitch their single-engine Gripen and F-16 planes that were eliminated in the Rafale tender.

"The Rafale is filling up one critical gap. It's not the whole envelope," Gokhale said. "Once this is over, the government will get down to business to assess the proposals."

India is the world's largest arms importer, and despite Modi's pledge to build a local manufacturing base, foreign defense firms view India as one of the most lucrative markets as Western states trim defense budgets.

($1 = 0.8920 euros)

(Reporting by Tommy Wilkes and Nigam Prusty; Editing by Sanjeev Miglani and Nick Macfie)