NEW DELHI (Reuters) - India's Supreme Court ruled on Wednesday that the government's imposition of direct rule in a remote northeastern state was illegal, and the dislodged opposition Congress party should return to power immediately.

The government imposed so-called president's rule in Arunachal Pradesh, a vast but sparsely populated state bordering China, in January after the Congress party that had been ruling there suffered splits which the government believed left it unable to govern.

The court's order for the reinstatement of Congress rule in the state is a blow to Prime Minister Narendra Modi's ambition of expanding the influence of his Bharatiya Janata Party (BJP) in the underdeveloped northeast.

"This court quashes the imposition of president's rule in Arunachal Pradesh," a five-judge constitution bench said in its ruling, calling the Congress party's dismissal "illegal and unconstitutional".

Congress, whose power base has shrunk across India since the BJP won a landslide general election in 2014, also saw its rule reinstated in May in Uttarakhand, another state where president's rule had been imposed as Modi's party attempted to wrest control.

The BJP scored its first state election victory in the northeast in May when it won in Assam, the region's most populous state, in a sign of its growing influence beyond its traditional heartland.

Congress is run by the fabled Gandhi dynasty that has led the world's largest democracy for most of its existence but now rules only a handful of India's 29 states, including in Arunachal Pradesh, home to 1.38 million people.

(Reporting by Tommy Wilkes and Suchitra Mohanty; Editing by Robert Birsel)