To build stateful firewall rules in iptables, the -m conntrack and --state options are used. The -m conntrack module allows for connection tracking, and --state tracks connection states like ESTABLISHED, RELATED, or NEW, ensuring that the firewall maintains awareness of connection states when filtering traffic. These options are critical for implementing a stateful firewall that tracks and manages active connections.