GAZA — A British journalist was freed here on Thursday after being held for 25 days by the Hamas authorities.

The journalist, Paul Martin, was arrested Feb. 14 at the trial of a Palestinian accused of collaborating with Israel. Mr. Martin had planned to testify on behalf of the man, a former member of a rocket-firing squad and the subject of a documentary Mr. Martin made in 2008.

Image The British journalist Paul Martin, left, being escorted by a member of Hamas after his release in Gaza City on Thursday. Credit... Ali Ali/European Pressphoto Agency

Mr. Martin left Gaza immediately after his release, after the authorities warned him not to return.

“I’m happy that I’m free,” he told reporters at the Erez crossing, where he was taken into Israel in a bulletproof vehicle belonging to the British Consulate.