Abstract. CAT(0) metric spaces constitute a far-reaching common generalization of Euclidean and hyperbolic spaces and simple polygons: any two points x and y of a CAT(0) metric space are connected by a unique shortest path (x, y). In this paper, we present an efficient algorithm for answering two-point distance queries in CAT(0) rectangular complexes and two of theirs subclasses, ramified rectilinear polygons (CAT(0) rectangular complexes in which the links of all vertices are bipartite graphs) and squaregraphs (CAT(0) rectangular complexes arising from plane quadrangulations in which all inner vertices have degrees 4). Namely, we show that for a CAT(0) rectangular complex K with n vertices, one can construct a data structure D of size O(n2 ) so that, given any two points x, y K, the shortest path (x, y) between x and y can be computed in O(d(p, q)) time, where p and q are vertices of two faces of K containing the points x and y, respectively, such that (x, y) K(I(p, q)) and d(p, q)...