Wireless sensor nodes are congenitally limited by insufficient hardware resources, such as memory size and battery life. These factors influence the lifespan of wireless sensor networks and pose numerous challenges regarding the addition of security mechanisms to protect sensor nodes. As the number of applications using wireless sensor networks increases, protecting sensor nodes from malicious attacks becomes ever more important. In this paper, we propose a new intrusion detection system called the Markovian IDS, to protect sensor nodes from malicious attacks. The Markovian IDS incorporates game theory with anomaly and misuse detection to determine the best defense strategies. It also employs Markov decision processes with an attack-pattern-mining algorithm to predict future attack patterns and implement appropriate measures. Experimental results show that the proposed Markovian IDS has a higher defense success rate than game theory or Markov decision processes alone.