Motivation: A fast growing number of non-coding RNAs have recently been discovered to play essential roles in many cellular processes. Similar to proteins, understanding the functions of these active RNAs requires methods for analyzing their tertiary structures. However, in contrast to the wide range of structure-based approaches available for proteins, there is still a lack of methods for studying RNA structures. Results: We present a new computational method named ARTS (alignment of RNA tertiary structures). The method compares two nucleic acid structures (RNAs or DNAs) and detects a-priori unknown common substructures. These substructures can be either large global folds containing hundreds and even thousands of nucleotides or small local tertiary motifs with at least two successive base pairs. To the best of our knowledge, this is the first method of this type. The method is highly-efficient and was used to conduct an all-against-all comparison of all the RNA structures currently available in the Protein Data Bank.