Representative Richard Hanna, Republican of New York, broke ranks with his party to endorse Hillary Clinton for president on Tuesday, denouncing Donald J. Trump’s attacks on the Muslim parents of a soldier killed in Iraq and calling Mr. Trump “unfit to serve.”

Mr. Hanna has long said he would not support Mr. Trump in the general election. By throwing his support to Mrs. Clinton, he becomes the first Republican member of Congress to go beyond disavowing Mr. Trump, and join forces with the Democrats against him.

Mr. Hanna announced his plans in an interview and opinion column on Syracuse.com. He cited Mr. Trump’s disrespectful comments about the soldier’s parents, Khizr and Ghazala Khan, among the reasons for his defection.

“I was stunned by the callousness of his comments,” Mr. Hanna said. “I think Trump is a national embarrassment. Is he really the guy you want to have the nuclear codes?”