During World War II , it was able to successfully defend its freedom and resist invasions by the Soviet Union - albeit with some loss of territory .