Two teenage girls have been charged in connection with a violent confrontation with a police officer in Brampton, Ont., which was caught on video and has received hundreds of thousands of views online.

Const. Fiona Thivierge of Peel Regional Police said the incident happened around 12:30 p.m. ET Tuesday as officers were investigating two female suspects for allegedly trespassing at St. Marguerite D'Youville school on Dixie Road.

A still taken from an online video shows the police officer getting hit by a girl in Brampton, Ont. (CBC)

Thivierge said a struggle broke out as one of the suspects was being arrested, and that the officer received minor injuries.

Neither suspect attends the school.

The video posted on YouTube shows what appears to be a female police officer getting hit repeatedly by one girl, and then getting subdued by the other teen when the first girl tries to run away.

CBC News has confirmed the legitimacy of the video with Peel Sgt. Matt Small, who said the officer is "fine," and will have "no lasting injuries."

The ages of the teens and charges against them are:

15-year-old: trespassing, obstructing a peace officer, assaulting a peace officer and assisting in escape from lawful custody.

16-year-old: trespassing, assaulting a peace officer and escaping lawful custody.

The teens are expected to appear in court on March 17.

Paul Black, president of the Peel Regional Police Association, said he had spoken with the officer, who is a six-year member of the force.

"She tells me she's doing fine. She's a humble officer who doesn't want this attention and she's back on duty today," he told reporters on Wednesday afternoon.

The officer, whose name has not been released, used pepper spray in an attempt to gain control of the situation.

"In the moment, she did what she had to do, there was nobody injured as a result of this, and the two parties are under arrest," Black said.

Asked why the officer didn't draw a gun or use a Taser, he said, "she deployed what she had on her at the time."

The video drew hundreds of thousands of views online and prompted some commenters to praise the officer for her restraint, while others questioned her training and response to the attack.

"The female police officer should be fired for being weak.… She's a danger for herself and the rest of society," one wrote.

"She kept her calm, she did not beat them as many cops would have, and in the end, she apprehended them," wrote another.

Several people suggested a police officer south of the border would have handled the incident differently.

"I don't think those two girls realize that if this were America, they would both be dead....." wrote another.

Black was critical of the person who made the recording.

"What's unsettling in this case is that the person on the video found this incident humorous. We can see the filmer is laughing and also found that that was his priority in this moment to capture an assault," he said.