Importance sampling has been reported to produce algorithms with excellent empirical performance in counting problems. However, the theoretical support for its efficiency in these applications has been very limited. In this paper, we propose a methodology that can be used to design efficient importance sampling algorithms for counting and test their efficiency rigorously. We apply our techniques after transforming the problem into a rare-event simulation problem—thereby connecting complexity analysis of counting problems with efficiency in the context of rare-event simulation. As an illustration of our approach, we consider the problem of counting the number of binary tables with fixed column and row sums, cj’s and ri’s, respectively, and total marginal sums d=∑jcj. Assuming that max jcj=o(d1/2), ∑cj2=O(d) and the rj’s are bounded, we show that a suitable importance sampling algorithm, proposed by Chen et al. [J. Amer. Statist. Assoc. 100 (2005) 109–120], requires O(d3ɛ−2δ−1) operations to produce an estimate that has ɛ-relative error with probability 1−δ. In addition, if max jcj=o(d1/4−δ0) for some δ0>0, the same coverage can be guaranteed with O(d3ɛ−2log(δ−1)) operations.