SARAJEVO/BELGRADE (Reuters) - The heaviest rains and floods in the past 120 years hit Bosnia and Serbia this week, killing three people, cutting off electricity and leaving several towns and villages isolated.

The three casualties, one of them a firefighter on a rescue mission, drowned in Serbia. The country declared a state of emergency in 18 towns and cities, including the capital, Belgrade.

Prime Minister Aleksandar Vucic said on Thursday he would declare an emergency for the whole country at 1100 GMT.

"This is the greatest flooding disaster ever. Not only in the past 100 years; this has never happened in Serbia's history," Vucic told a news conference. "More rain fell in one day than in four months."

In Bosnia, army helicopters evacuated dozens of people stranded in their homes in the central town of Maglaj, where the Bosna river swelled to record levels, reaching the first floors of apartment buildings.

Special police were trying to reach the northern Bosnian town of Doboj, which was cut off from the rest of the country after all major roads out were flooded.

The Bosnian government ordered the defence ministry to use troops to help thousands of civilians whose homes were engulfed by water, particularly in the central and eastern regions.

"This is the worst rainfall in Bosnia since 1894, when weather measurements started to be recorded," said Zeljko Majstorovic, a Sarajevo meteorologist. He said the rain, which began on Tuesday, would continue until the end of the week.

Many roads were deluged and towns and villages completely cut off. Schools were closed across both countries.

Serbian Energy Minister Aleksandar Antic said power supplies were cut to around 100,000 households, mostly in central Serbia.

Serbia's power company, Elektroprivreda Srbije, said it had mobilised teams to monitor the situation on the ground. Flooding had disrupted production in two coal mines supplying major thermal plants, the company said.

A major highway from Belgrade to Macedonia and Bulgaria was flooded and the traffic interrupted. The main south-bound railway line to Montenegro's port of Bar was also closed down.

Bosnia's top utility, Elektroprivreda BiH, said at least 5,000 households were without electricity in the central and eastern parts of the country.

(Writing by Daria Sito-Sucic; Editing by Zoran Radosavljevic and Larry King)