For 300 years , until forcibly united in the late 18th century , they were separate kingdoms with related , but not always friendly , Malla rulers .
The kingdoms were sometimes at war , but often allied against other threats .