Police shot dead an armed man when he went into a church with a gun because he was 'distraught over a relationship', police said.

Santa Ana police officers fatally shot the armed man on Sunday afternoon inside a Catholic church, just before a service was due to start.

He was shot at the altar after officers were flagged down at 4.20pm and told someone inside Immaculate Heart of Mary Church had a gun.

Officers found the armed man inside the building and opened fire, according to local media.

The man then ran outside with the weapon and collapsed on a nearby street.

Santa Ana detectives and officers investigating the scene where an armed man was shot by police at Immaculate Heart of Mary Church in Santa Ana, California on Sunday afternoon

Police detectives huddling underneath umbrellas at the scene in Sana Ana on Sunday

He was pronounced dead at the scene, police Cpl. Anthony Bertagna said.

Bertagna told the Orange County Register: 'We understand he was distraught over a relationship. We're not sure if that's why he was here.'

Police Chief David Valentin said witnesses reported the man was distraught and possibly suicidal, but it did not appear he was planning a mass shooting.

'It's tragic, it really is. Any loss of life, it's tragic. In this circumstance, it's a place of worship', Valentin said.

'People come here for comfort, spiritual healing, support, so for this to happen here it's traumatic for everyone involved.'

Officers were told by people inside the church, who had arrived for a 5pm service, that another person may have been with the suspect.

Santa Ana Police detectives standing by the scene on Sunday. Officers fatally shot an armed man inside the Catholic church

The church and a nearby school was searched by officers, but by early Sunday evening had not yet found another suspect, Bertagna added.

Police withheld the suspect's name pending notification of family.

Maria Roque, 39 of Santa Ana, a member of the church, told the Register that she, like the others, was surprised to find out a shooting occurred.

Friends were in the library inside the church when the shooting took place, but they were all safe, she said.

'It's scary to think we're not even safe here,' Roque said. 'I've been coming here since I was 16 years old.'