An American freelance journalist has been released from an Indonesian jail after serving a 40-day sentence for immigration offenses.

William Nessen left Banda Aceh Sunday, one day after the district court sentenced him. The court gave him credit for time served since June 24, when he was detained while reporting on a separatist war in Indonesia's Aceh province.

The Aceh court found Nessen guilty of violating his visa by contacting rebels in the province and failing to inform authorities. He surrendered to Indonesia's military after traveling for three weeks with members of the Free Aceh Movement.

The 46-year-old native of New York City said he is returning to the United States to visit his parents and seek medical treatment for kidney stones.