A suspected gunman tried to shoot up a mosque in Norway over the weekend in an attempted terrorist attack that officials first caught wind of last year — but failed to act on, a police official admitted Monday.

Philip Manshaus was arrested after opening fire Saturday at the Al-Noor Islamic Center in Baerum, an Oslo suburb — an attack that was thwarted by a 65-year-old man who overtook Manshaus.

Three men were inside the house of worship at the time, preparing for Sunday’s Eid al-Adha Muslim celebrations. No one was injured.

The 21-year-old suspect looked significantly bruised and scratched in his first court appearance in Oslo, where he was photographed smiling. He did not speak during the closed-door hearing. It was unclear how he received the injuries.

Hans Svrerre Sjoevold, the head of Norway’s domestic security agency PST, admitted officials had a “vague” tip a year ago about Manshaus — but said it wasn’t sufficient to act on because they had no information about any “concrete plans” of an attack.

He said the information “didn’t go in the direction of an imminent terror planning.”

Police later found the accused gunman’s 17-year-old stepsister dead when they searched his apartment after the botched attack. He is now suspected in her death but has not been charged.

Before the attempted attack at the mosque, online postings under Manshaus’ name emerged expressing support for the shootings at two mosques in New Zealand that left 51 dead and the Aug. 3 massacre in El Paso, Texas, where 22 died.

His lawyer declined to comment on reports that Manshaus was inspired by those shootings.

Manshaus was ordered held for four weeks, including two in solitary confinement, while police investigate.

The attack at the Norwegian mosque comes in wake of the El Paso shooting, as well as the one in Dayton, Ohio, that left a combined 31 people dead.

With Post wires