In P2P networks, self-organizing anonymous peers share different resources without a central entity controlling their interactions. Peers can join and leave the network at any time, which opens the door to malicious attacks that can damage the network. Therefore, trust management systems that can ensure trustworthy interactions between peers are gaining prominence. This paper proposes AntTrust, a trust management system inspired by the ant colony. Unlike other ant-inspired algorithms, which usually adopt a problem-independent approach, AntTrust follows a problem-dependent (problem-specific) heuristic to find a trustworthy peer in a reasonable time. It locates a trustworthy file provider based on four consecutive trust factors: current trust, recommendation, feedback, and collective trust. Three rival trust management paradigms, namely, EigenTrust, Trust Network Analysis with Subjective Logic (TNA-SL), and Trust Ant Colony System (TACS), were tested to benchmark the performance of AntTrust. The experimental results demonstrate that AntTrust is capable of providing a higher and more stable success rate at a low running time regardless of the percentage of malicious peers in the network.