A community in Montgomery County, Pa., has been rocked by recent sightings of a man walking around with an AR-15 rifle.

It happened in Abington Township, a moneyed suburb of Philadelphia, and it prompted the township's police chief to issue public warnings about the armed man.

Now as 6ABC reports, the man has been taken into custody over concerns related to his mental health.

The man, who is a township resident and had attended Abington High School as recently as 2017, was not charged with a crime. His identity is being withheld by police.

Instead, the man was taken into custody late last week on an involuntary mental health warrant, 6ABC reports, adding:

Abington Chief Patrick Molloy emphasized that the man's decision to carry the rifle in public did not, by itself, spark the decision to take him into custody.

"This case illustrates the very complex nature of balancing an individual's Second Amendment rights with our primary mission to protect and serve all our residents," Molloy told 6ABC.

Rather, police acted after some of the man's friends messaged police via Facebook with concerns about his behavior and change in mental status.

One witness told police the young man talked of "shooting up" Penn State Abington back in January.

More recently, the man texted the friend a picture of the AR-15, saying "look what I just got."

The friend told detectives, "I think he... is throwing up some red flags because he recently dropped out of school. He gave me the impression he feels he has nothing to lose, in a way."

According to court records, detectives searched the man's smartphone and found internet searches including: 'Parkland shooter,' 'law enforcement visits,' 'what weapons were used at Columbine,' and 'where to most mass shootings occur,' 6ABC wrote.

Police have secured the AR-15.