A Republican candidate for the Maine State House who disparaged two teenage survivors of the school shooting in Parkland, Fla., dropped out of the race after drawing heavy criticism and challengers from both political parties.

The candidate, Leslie Gibson, had been running to represent District 57 in central Maine unopposed, according to The Sun Journal, which first reported the comments he made on Twitter. Mr. Gibson called one Florida student, Emma González, a “skinhead lesbian,” and another, David Hogg, a “moron” and a “baldfaced liar.”

Some state lawmakers, including at least two Republicans, were quick to condemn Mr. Gibson after his comments surfaced. Mr. Hogg issued a call on Twitter for someone to run against Mr. Gibson. By Thursday, two challengers who had been dismayed by the remarks were scrambling to complete the paperwork needed to run for the seat before the filing deadline that night.

By Friday, at least one Democrat, Eryn Gilchrist, and one Republican, Thomas H. Martin Jr., had entered the race and Mr. Gibson had withdrawn.