In this paper, we design and implement a distributed Internet of Things (IoT) framework called IoT-guard, for an intelligent, resource-efficient, and real-time security management system. The system, consisting of edge-fog computational layers, will aid in crime prevention and predict crime events in a smart home environment (SHE). The IoT-guard will detect and confirm crime events in real-time, using Artificial Intelligence (AI) and an event-driven approach to send crime data to protective services and police units enabling immediate action while conserving resources, such as energy, bandwidth (BW), and memory and Central Processing Unit (CPU) usage. In this study, we implement an IoT-guard laboratory testbed prototype and perform evaluations on its efficiency for real-time security application. The outcomes show better performance by the proposed system in terms of resource efficiency, agility, and scalability over the traditional IoT surveillance systems and state-of-the-art (SoA) approaches. INDEX TERMS IoT, edge, fog, video surveillance, convolutional neural network, motion detection, gun-knife detection, real-time security, message queuing telemetry transport (MQTT).