The FBI thwarted a potential terrorist attack planned for New Year's Eve, the US Justice Department released on Friday.

The suspect, Christan Sturdivant, is an 18-year-old US citizen who pledged himself to ISIS and claimed he planned to "do Jihad soon" to someone he thought was another terrorist sympathizer, but was in fact an undercover law enforcement officer.

He planned to attack civilians at a grocery store with a hammer and knives, which the FBI found hidden under his bed during a search of his home.

"We allege Sturdivant was willing to sacrifice himself by committing a terrorist attack using knives and a hammer to support the murder, torture, and extreme violence that ISIS represents," FBI Special Agent James Barnacle said during a press conference.

Sturdivant was allegedly in contact with an overseas, unidentified ISIS member online who told him to attack people with a hammer.

"This investigation highlights the very real threat posed by people who self-radicalize online and are inspired by jihadist ideologies espoused by foreign terrorist organizations," Barnacle added.