Yugoslavia had 305 000 deaths, whilst much bigger states, like USA or Britain had only 100k more. I thought only local partisans fought and the country was relatively peacefully liberated by Red Army, when Tito took the lead. So, what happened?
After Romania, Hungary, and Bulgaria signed the Tripartite Act (An agreement basically between these states and Nazi Germany), there was incredible division between the people of Yugoslavia about whether they should side with the Germans or not. Since there was a coup that got rid of the King, it was very chaotic so the Germans entered the state to eliminate opposition while at the same time, those that did want German occupation fought the resistance as well.
So in short, Germans attacking resistors, Yugoslavians attacking resistors, and a whole lot of death.
This is VERY simply put, obviously there are a lot more details involved.
Source: Keegan, John. "The Second World War". New York: Penguin Books, 1989. (pg 151-56)
I'm not sure what that military column on a linked page includes. If it is only Yugoslav royal army in the time Yugoslavia still existed, than it is way too high, the war lasted for some 10 days in April 1941 before Yugoslavia totally disintegrated. That number however could include Četniks (officially called Yugoslav army in the homeland, roughly translated), but that would be quite wrong because they rather quickly started to collaborate with Italians and Germans.
Civilian and total columns are off as well. Best estimates (Žujović for example, but accepted by most serious research on war deaths and demographers) puts total war death at 1.024.000 with 1.6 million being the demographic loss (including emigration, reduced birthrates, etc.)
(As a side note: Yugoslavia officially claimed 1.6 million war death, sort of by accident on purpose. More or less accurate estimates were available soon after the war, and the demographic loss was reported as actual war deaths for bigger war reparations. So, 1.6 million was "accidentally" misunderstood as the war deaths)
Now, all that is not saying Yugoslav losses were not horrible, 1 million in a country of than 17 million people. Relative to population, it is comparable to Soviet Union or Poland.
Several factors explain those high losses. First is the resistance and German retributions, that never really achieved the stated ratio of 50 people for a wounded and 100 for killed German soldier, but at times were close. Another is the multiple conflicts going on at the same time. Major armed forces in Yugoslavia during the war included: German and Italian occupation forces, Četniks and Ustaše (Serbian and Croatian quisling forces respectively, both with their own genocidal projects), Nedićevci and Domobrani (official quisling forces of Serbian and Croatian states, recrutes mostly without strong political motivation), Belogardejci (similar but for Slovenia), and Partisans (communist guerrillas).
There were also multiple conflicts going on: occupation and resistance (mostly by Partisans), ethnic conflicts (mostly between Serbs and Croats), civil war (mostly between Partisans and royalist, and between Partisans and different quislings). Due to large number of unofficial armed forces, the lines between civilian and military is very much blurred. For example, were people faced with execution on ethnic bases who took up arms and went from their village to mountains civilians or military? Those multiple conflicts however, help explain both high losses and difficulty of their categorisation.
I thought only local partisans fought and the country was relatively peacefully liberated by Red Army, when Tito took the lead.
This is actually a misconception. There were several yugoslav groups fighting besides the Partisans (who were led by Tito form the start). The Red Army doesn't have a direct impact in Yugoslavia, they never touched the terrority. Yugoslavia was freed by the Partisans themselves, which is also why they weren't part of the Eastern bloc and which also led to the Tito-Stalin split. Also I defenitly would say that nothing was relatively peaceful regarding Yugoslavia, even the aftermath wasn't if you look at the Massacre at Bleiburg.