Militants overran an army base in northeastern Nigeria, killing more than 30 soldiers before pulling back in the face of air strikes, soldiers and a resident said.