In his blog, Khazali has criticized Iranian President Mahmud Ahmadinejad and Iran's state policies.
Khazali’s lawyer told RFE/RL's Radio Farda that he will appeal against the sentence.
Khazali was arrested about a month ago and is currently on a hunger strike. The outspoken blogger and ophthalmologist has been detained a number of times in the past two years.
Meanwhile, Iranian authorities have arrested several people over alleged links to the BBC's Persian service, Iran's semiofficial Mehr news agency reported on February 6.
Quoting an unnamed “informed source,” Mehr said the detainees produced content and reported to the BBC. It is not clear how many people have been arrested.
In London, the BBC said in a statement it has "no BBC Persian staff members or stringers working inside Iran."
The BBC said the report "should be of deep concern to all those who believe in a free and independent media.”
In October, Iran released two filmmakers who were jailed on similar charges. Last week, the BBC accused Iran of pressuring the staff members of its Persian service by targeting their relatives in Iran.