* RWE's western German Garzweiler mining can continue unhindered
* Ruling safeguards role of brown coal burning for electricity
* Local residents' concerns must be addressed earlier on (Adds comments from RWE, financial analyst, lawyer, share price)
KARLSRUHE, Germany, Dec 17 Germany's highest court said the rights of citizens must be respected when it comes to brown coal mining, but stopped short of interfering in an activity that represents one of the most profitable sources of power generation for RWE.
A widely awaited ruling on Tuesday by Germany's Federal Constitutional Court said that any relocation and compensation for residents near RWE's Garzweiler mine, which could continue operating up to 2045, should be worked out early, so as to allow citizen's concerns to be dealt with appropriately.
But brown coal mining itself and the use of domestic raw materials overall was not in question, the court said, adding these matters were up to the government.
"Brown coal mining secures a sufficiently legal and sustainable public benefit," it said.
A negative ruling on the mining sector could have spelled early closure for the mine and an important structural change to the power generation mix for utilities.
RWE operates thousands of megawatts of brown coal-to-power capacity in its core North-Rhine Westphalia region and needs local supplies to fuel them, producing between 35 and 40 million tonnes annually.
German brown coal, also mined by Vattenfall in eastern Germany, supplies 25 percent of the country's power generation. Brown coal mining has come under fire from local residents, some of whom will be relocated in future expansion programmes, but also from environmentalists for the high carbon dioxide pollution it emits during burning.
An RWE spokeswoman said the firm welcomed the decision as it gave people in the Garzweiler mining region certainty that mining would continue.
RWE in October denied a report it was considering the early closure of the mine, though it is pressing ahead with restructuring measures due to the unprofitable wholesale market for power.
Garzweiler feeds raw material to RWE's power plants G and F at Neurath, among others, which since opening in 2012 have been among the world's biggest and most modern brown coal-to-power blocks with a joint capacity of 2,100 megawatts.
"If this had turned out negatively, RWE would have had a problem because the Neurath blocks ... were built (to be operated) for 30 to 40 years," said Roland Vetter, head of research at London-based CF Partners, an energy advisory, trading and investment firm.
"It would have hurt if these blocks had been stopped, or forced to run at less than full capacity after a few years."
But a lawyer who has represented property owners affected by mining, Michael Terwiesche, said that in his view the rights of local people had been strengthened by the decision, as they would be heard before firms even filed planning applications.
"It will get more difficult, more protracted, and more expensive for mining firms to carry on," he said from his Duesseldorf practice.
RWE shares were 0.8 percent down while the blue chip DAX index lost 0.2 percent.
(Reporting by Norbert Demuth, Tom Kaeckenhoff, Vera Eckert; Editing by Mark Potter and David Evans)