A court in Namibia has dismissed a case against a photographer who allegedly trespassed on a roof to try to take a picture of actress Angelina Jolie.
Jolie has employed heavy security to maintain her privacy
John Liebenberg, 48, was released with a warning after three days in custody.
The judge said he could not understand why Mr Liebenberg, of South Africa, was detained by police for so long.
Jolie, whose baby is due this month, has been protected by heavy security since arriving in Africa with her partner Brad Pitt six weeks ago.
Mr Liebenberg, a veteran photo-journalist, was taken into custody after driving into the rear of a police station in the port town of Walvis Bay.
He had received a tip-off that Jolie was about to give birth at a private hospital there.
Police claimed he had been searching for a vantage point to take a picture of the building's entrance.
"It might be that you are a foreigner and that you were arrested for trespassing, [but] why was it necessary to keep you in custody for the whole weekend?" Walvis Bay magistrate Sarel Jacobs asked in court.
"I don't understand that and I think it was unnecessary," he added before dismissing him.
The prosecution had asked for a fine of 1,000 Namibian dollars (£80) or a year in prison.
Mr Liebenberg told Reuters press agency after the hearing that police may have wanted to use his case as a warning to other photographers and media.
"They probably wanted to make an example of me to the other so-called nasty paparazzi press. But we have been very respectful to [the couple]," he said.
Pitt and Jolie - who have been dubbed "Brangelina" by the press - have sparked a media frenzy during their time in southern Africa.
Bodyguards and undercover Namibian police officers have shielded them from journalists, erecting green cloth screens around the beach resort where they are staying.