Gestures are natural and easy means as user interfaces (UI) because they have been employed in daily life. Recently, mobile devices equip a triaxial acceleration sensor which allows the gesture inputs. Many systems have been presented for the motion-based interfaces, yet only few are considered the insufficient computing power of the mobile devices. This paper proposes a selective template matching algorithm based on dynamic time warping (DTW) and naïve Bayes classifiers for gesture-based UI. It is composed of three parts: template estimation, model selection, and recognition. The preprocessing reduces the length of acceleration vectors, while the template estimation and model selection lessen the number of matching sequences of DTW where K-means clustering and a naïve Bayes classifier are adopted respectively. The proposed method recognizes short and intuitive 20 gestures designed for the mobile UI, such as snapping, bouncing, rotating, tilting, tapping, and shaking. Experimental results with the mobile implementation have validated the effectiveness of the proposed method in terms of accuracy and computation efficiency.