Hashmi, a senior vice president of the Muslim League, is the effective leader of the party due to the exile of its normal leader Nawaz Sharif, a former prime minister.
Hashmi has been ordered to submit a bail bond of $830, a court spokesman said.
He said Hashmi's appeal against his conviction is still pending.
"I have finally got justice and I am happy over it," Hashmi said by telephone from the jail where he is being held, in the eastern city of Lahore.
He said he expects to be released when the bail is posted on Saturday.
Hashmi was arrested in October 2003 and charged with defaming the government and the army, document forgery and incitement to mutiny. He was sentenced in April 2004.
The letter that Hashmi allegedly distributed was apparently from some Pakistani soldiers, criticising Musharraf for making Pakistan a US ally in Afghanistan.
The letter apparently praised parliament for opposing a US request for Pakistan to send troops to Iraq.
The ruling to release Hashmi comes as Musharraf faces a growing number of legal challenges to his authority, in the run-up to general elections next year.
Sharif lodged an appeal on Thursday for an end to his seven-year exile from Pakistan, ostensibly to challenge Musharraf in the general elections.
Musharraf overthrew Sharif in a coup in 1999.
Sharif was sentenced to life in prison on tax evasion and treason charges but was permitted to go into exile in Saudi Arabia in 2000.
Bearing on case
The Muslim League said the reinstatement of Chaudhry to his post as chief justice had a bearing on Hashmi's release.
"We got justice because the judiciary got independence after the chief justice events," Farooq said.
Musharraf is expected to seek re-election as president-in-uniform by parliament, defying the constitution which says he should quit his military role by the end of 2007.
He held private talks in Abu Dhabi last week with another Benazir Bhutto, a former prime minister, on a possible power-sharing deal.