(CNN) -- Two American hikers accused of being spies in Iran will be released from an Iranian prison after a $500,000 bail is paid for each of them, their attorney said Tuesday.
Josh Fattal and Shane Bauer, who were sentenced to eight years in an Iranian prison, are a pair of friends who love to travel and be immersed in other cultures, according to friends and associates.
They have been in Iranian custody for two years since they and a third hiker, Sarah Shourd, were detained on spying charges. They had been hiking in the Iraqi Kurdish region and allegedly crossed into Iran illegally.
Shourd, Bauer's fiancee, was released last year because of medical reasons, but Fattal and Bauer faced an extended prison sentence.
Bauer was working as a freelance journalist and had been undertaking a yearlong visit to the Middle East at the time of their arrest.
In the Middle East, Bauer planned to spend time "absorbing on the ground whatever he could in the Arab world and offered to contribute stories to us," Sandy Close, executive director of California-based New America Media, told CNN in 2009.
"I think this is a very experienced traveler, a backpack kind of traveler, not somebody who would go to the Ritz Carlton," Close said of Bauer. "[He's] somebody who would go to the hostel, who would operate on a shoestring, as many freelancers do."
Bauer was planning to write a story about elections in Iraqi Kurdistan at the time the trio went hiking near the Iranian border.
"I think he went to [Iraqi] Kurdistan to cover the elections ... and [during a hike] unfortunately didn't know the ground he was walking on well enough to avoid crossing over whatever boundary was there," Close said.
A 2007 honors graduate in peace and conflict studies at Berkeley, Bauer is fluent in Arabic, Close said.
Though he knows Arabic and is comfortable with Arab culture, he doesn't understand Farsi and therefore "would not have been able or, I think, interested in going [into Iran]," Close said.
Fattal graduated from Berkeley in 2004 with a bachelor's degree in environmental economics and policy, the university said.
He shares his friends' love of travel and learning, and was described as "fiercely intellectual" by his friend, Chris Foraker, who spoke to CNN affiliate KVAL in Eugene, Oregon, in 2009.
Foraker said he met Fattal during a study abroad program in 2003, and the two worked together at the nonprofit Aprovecho sustainable living research center in Cottage Grove, Oregon.
"[Fattal] is a really great guy. We had a really good working relationship with him, and we love him a lot and hope to see him home safe soon," said Aprovecho's Jeremy Roth, who spoke to CNN affiliate KEZI in Eugene at the time of his arrest.