SOFIA, Bulgaria (AP) _ The surprise election Friday of a politically independent judge to succeed Premier Andrei Lukanov filled Bulgaria's leadership void, but the economic troubles that helped topple Lukanov persist.

''I don't want to offer the nation a cruel program,'' said Premier Dimitar Popov, head of Sofia's municipal court, ''but I don't promise anything rose- colored.''

Popov, 63, who does not belong to any political party, was nominated earlier Friday by President Zhelyu Zhelev to succeed Lukanov, who resigned Nov. 29 following protest strikes and demonstrations. Popov will head a transition government until elections next summer.

His election by the 400-seat Grand National Assembly settled the lingering question over who would run the country.

Parliament ordered him to present his government to the chamber within seven days. Meanwhile, foodstuffs and electricity are rationed. Many other everyday needs are in very short supply.

The government announced last spring that it was unable to service the country's $11 billion foreign debt and has been seeking assistance from the West.

Since Lukanov's resignation, Bulgaria has been run by Lukanov's Socialist government of former Communists on a caretaker basis.

''My activity resembles a painful operation in order to save a state and a people,'' said Popov, who helped run Bulgaria's first free elections in June. ''This is an attempt at a strong government of professionals and politicians.''

Popov also told Parliament he was accepting the job provided he gets broad support from legislators and the public.

Assembly chairman Nikolai Todorov announced Popov was elected by a ''large majority,'' but did not give the number of assembly deputies who voted for him. He said 15 deputies voted against Popov and 29 abstained.

His unexpected appointment came after Ginyu Ganev, the deputy chairman of parliament, refused the post. Sources said that Todor Valchev, an economics professor, also had turned it down.

''We must all realize that the issue of political power is not the most important one, but that ... of whether Bulgaria can survive,'' said Alexander Tomov, deputy chairman of the Socialist Party.

''Dimitar Popov is a suitable candidate, both as a personality and as a neutral figure,'' Lukanov said.

He lauded Popov as ''a man with character ... who has shown in complicated situations that he can be non-partisan and objective.''

Popov, the son of an Orthodox priest, was born in the northern Bulgarian city of Kula. He studied law and worked for 35 years as a lawyer for transport companies and later as a judge.

''I am neutral as regards my non-membership in a political force, but I am strongly committed to the ideals of democracy,'' Popov said.

''I appeal to all political forces and labor unions to support this (future) government within the framework of the political agreement that has to be signed within the next few days,'' Zhelev told deputies.

He referred to an accord being negotiated under his auspices to establish a transitional government, set a timetable for future legislative work and the drafting of a new constitution.

But in his speech, Zhelev introduced the new premier without a word on his qualifications. Rather, he heaped praise on the outgoing Lukanov.

''Andrei Lukanov stepped down, not because he did not have the necessary qualities of a politician,'' he said. ''He is one of Bulgaria's most capable politicians and the most outstanding one in his party.''

''His political drama is not of a personal nature, it is the drama of a political party doomed to separate from state power,'' the president said.

He also said that ''politicians of Lukanov's caliber and abilities must not disappear from the political life of the country. His knowledge, relations and know how are necessary for the country. Bulgaria does not have so many capable politicians.''

But analysts said Lukanov was unlikely to join Popov's Cabinet.

Zhelev had tried hard to set up a coalition government under Lukanov, but the Union of Democratic Forces, the main opposition alliance, rejected it. The alliance asserted that Lukanov was compromised by his Communist past.

The Union of Democratic Forces was shaken this week by revelations that its chairman, Petar Beron, was a police informer under the former regime of Communist dictator Todor Zhivkov.

Beron's resignation was accepted Thursday. He admitted he informed on foreign visitors while working at the Natural History Museum. But Beron said he reported to a department other than the dreaded domestic secret police.