With the rapid growth of large-scale knowledge bases (KBs), knowledge base question answering (KBQA) has attracted increasing attention recently. Relation detection plays an important role in the KBQA system, which finds a compatible answer by analyzing the semantics of questions and querying and reasoning with multiple KB triples. Significant progress has been made by deep neural networks. However, existing methods often concern on detecting single-hop relation without path reasoning, and a few of these methods exploit the multihop relation reasoning, which involves the answer reasoning from the noisy and abundant relational paths in the KB. Meanwhile, the relatedness between question and answer candidates has received little attention and remains unsolved. This article proposes a novel knowledge-based reasoning network (KRN) for relation detection, including both single-hop relation and multihop relation. To address the semantic gap problem in question-answer interaction, we first learn attentive question representations according to the influence of answer aspects. Then, we learn the single-hop relation sequence through different levels of abstraction and adopt the KB entity and structure information to denoise the multihop relation detection task. Finally, we adopt a Siamese network to measure the similarity between question representation and relation representation for both single-hop and multihop relation KBQA tasks. We conduct experiments on two well-known benchmarks, SimpleQuestions and WebQSP, and the results show the superiority of our approach over the state-of-the-art models for both single-hop and multihop relation detection. Our model also achieves a significant improvement over existing methods on KBQA end task. Further analysis demonstrates the robustness and the applicability of the proposed approach.