A five-day espionage dispute between West and East Germany came to an amicable end today when a West German prosecutor dropped spying charges against a prominent East German economist and allowed him to return home.

West German national prosecutor Kurt Rebmann canceled an arrest warrant for economist Herbert Meissner, who then left his refuge here in East Germany's diplomatic mission and returned to his own country.

The prosecutor's action reflected the Bonn government's desire to curb damage to relations between the two Germanys caused by the Meissner affair. Rebmann cited a legal loophole that permits the dropping of charges when such action is in the "national interest."

The curious case, which began when Meissner was detained July 9 in West Berlin for shoplifting a shower hose worth $14, was described by a West German official as "just a bit of summer theater."

The West German government said Meissner sought to defect to the West after his arrest, but that he then changed his mind and hid out in the mission early last week.

East Germany charged instead that West German intelligence agents had "kidnaped" and drugged Meissner, but that he had escaped from them. East German statements warned of serious consequences for relations with Bonn if Meissner was not permitted to return.

Bonn let Meissner go today after West German officials met with him for an hour to confirm that he genuinely wished to go home. West German officials also said privately that Meissner's spying had consisted only of making routine reports to East Germany's Ministry of State Security after the economist's trips to western countries.

The Bonn government had hoped to avoid a confrontation all along over Meissner, but prosecutor Rebmann upset the government's plans when he filed the spying charges on July 16. Meissner was unable to leave the East German mission while the charges were outstanding.

"The return of Mr. Meissner was in our interest and in the interest of German-German relations," Bonn government spokesman Friedhelm Ost told a news conference. He said that West Germany had neither demanded nor been offered concessions in exchange for permitting Meissner's return.

Meissner, deputy chairman of East Germany's Academy of Sciences, originally sought to defect because he panicked following the arrest for shoplifting, according to West German press accounts quoting government sources.

Meissner then was flown from West Berlin to the headquarters of West Germany's intelligence service near Munich. There he signed statements saying he was coming to the West of his own free will, and that he had performed espionage tasks during previous trips to the West, according to Bonn's account.

It was unclear whether Meissner, after he later decided not to defect, managed to slip away from West German security agents or simply was not being watched by them.