Although the emerging edge computing paradigm offers a promising approach to overcoming some limitations of conventional cloud computing, the heterogeneous edge nodes with highly diverse system capacities bring new challenges to service provisioning especially for latency-sensitive services. Cooperative edge computing (CEC) has been proposed for facing such challenges through resource sharing among edge nodes. However, some technical issues must be fully addressed to make CEC effective, among which incentive and trust mechanisms and performance optimization are crucial for latency-sensitive service provision. In this paper, we design a novel blockchain-based intelligent edge cooperation system named BIECS to tackle these challenges systematically. BIECS provides incentive to edge nodes for resource sharing and enables trust among cooperative nodes upon a distributed platform leveraging the blockchain technology. In order to optimize system performance for meeting the requirements of latency-sensitive services, we propose a two-stage strategy for node selection in BIECS that chooses the most appropriate edge nodes for executing offloaded tasks and recording related transactions in the blockchain. We also implemented a prototype of BIECS based on Hyperledger Fabric and conducted extensive experiments for evaluating the performance of BIECS. The obtained experiment results verify that the proposed BIECS achieves better performance in system delay and throughput compared to the state-of-the-art methods for edge cooperation.