Three people were killed in a shooting at the Islamic Center of San Diego on Monday, in an attack on the city’s largest mosque that police are investigating as a hate crime.

San Diego police said they received reports of a shooting at the centre at about 11:43 a.m. local time. Among those killed was a security guard at the mosque. The two teenage suspects were found dead a short time later in a vehicle parked nearby, both with what investigators described as self-inflicted gunshot wounds.

Police identified one of the suspects as a 17-year-old. The second was 19. Officers said they discovered anti-Islamic writing in the BMW in which the pair were found, and that one of the attackers had taken a firearm from his parents’ home and left behind a note containing writings about racial pride.

A relative of one suspect had contacted police before the attack to report that he was missing and had expressed suicidal thoughts, according to investigators, who said the warning was being examined as part of the wider inquiry.

The mosque also houses a school. Its imam said teachers, students and staff were evacuated safely as the attack unfolded, and that the building was secured by officers within minutes.

The Federal Bureau of Investigation is assisting the San Diego Police Department with the investigation, a standard step in cases with a suspected bias motive. Officials cautioned that the inquiry remained in its early stages and that the full circumstances had yet to be established.

President Donald Trump and California Governor Gavin Newsom were both briefed on the shooting, officials said. The attack drew immediate condemnation from civil-rights groups and Muslim community organisations, which called for heightened protection at places of worship.

The Islamic Center of San Diego, in the city’s Clairemont district, is one of the oldest and largest mosques in southern California and serves thousands of worshippers. Community leaders said grief counsellors would be made available and that the centre would remain closed while the investigation continued.