Security forces on Tuesday averted a tragedy with the timely detection of an improvised explosive device (IED) in Jammu and Kashmir's Shopian district, officials said.