In this paper, a dynamic multi-ary query tree (DMQT) anti-collision protocol for Radio Frequency Identification (RFID) systems is proposed for large scale passive RFID tag identification. The proposed DMQT protocol is based on an iterative process between the reader and tags which identifies the position of collision bits through map commands and dynamically encodes them to optimize slots allocation through query commands. In this way, the DMQT completely eliminates empty slots and greatly reduces collision slots, which in turn reduces the identification time and energy costs. In addition and differently to other known protocols, the DMQT does not need to estimate the number of tags, reducing the protocol implementation complexity and eliminating the uncertainty caused by the estimation algorithm. A numerical analysis shows that DMQT has better performance than other algorithms for a number of tags larger than 300. Meanwhile, when the number of tags is 2000 and the tag identity (ID) length is 128 bits, the total identification time is 2.58 s and the average energy cost for a tag identification is 1.2 mJ, which are 16.9% and 10.4% less than those of state-of-the-art algorithms, respectively. In addition, a DMQT extension based on ACK command has also been presented to deal with capture effect and avoid missing identification.