Iran has freed a prominent human rights lawyer after he spent more than five months behind bars amid widespread anti-government protests.