Although Croatia declared its independence from Yugoslavia in 1991 , it took four years of sporadic , but often bitter , fighting before occupying Serb armies were mostly cleared from Croatian lands .