Militants opened fire on a security post in northwest Pakistan late on Thursday, killing at least six personnel, the military said in a statement on Friday.