An elementary school teacher in Montana is accused of sexually assaulting two girls during class — giving them backrubs and touching their private parts, court documents show.

Brent David Skelton, a 30-year-old fifth-grade teacher at Orchard Elementary School in Billings, was arrested late Thursday after two 11- and 12-year-old girls told police that he would give them unwanted attention in class, KRTV reported.

One of the girls said Skelton would touch her body where she would “go pee,” while another student said she regularly saw the teacher touching the girls and was uncomfortable with his actions, according to court documents obtained by the station.

Detectives also found “flirtatious or sexually suggestive” text messages from Skelton on the girls’ cellphones, Yellowstone County prosecutors said.

Investigators learned of the allegations in July upon receiving a report from a parent about the incidents, which took place during the 2018-19 school year, the Billings Gazette reported.

A district investigator said one of the students appeared to be “protective” of Skelton, who would give her and another girl preferential treatment by buying them leftover food or treats from Dairy Queen, they told authorities.

A third student also told police that they saw one of the girls sitting on Skelton’s lap “almost every day,” the newspaper reported.

Skelton, who had been on leave since the accusations were reported, has not had any interaction with students this year and resigned his position following his arrest late Thursday, KULR reported.

Skelton remained held Monday on $150,000 bond on two counts of felony sexual assault, jail records show. He’s scheduled to be arraigned Tuesday.