A black Maryland lawyer who was detained in court earlier this month by a deputy who thought he was a suspect masquerading as a lawyer filed a complaint with the Harford County Sheriff’s Office this week, alleging the action was racially motivated.

The lawyer, Rashad James, who works for Maryland Legal Aid’s community lawyering initiative, has asked the Sheriff’s Department to begin an internal investigation and to record the complaint in the deputy’s personnel file.

Mr. James appeared at a hearing at Harford County District Court on March 6 on behalf of a client, who was not present. A sheriff’s deputy approached Mr. James in the hallway after the hearing and called him by his client’s name, according to the complaint.

Mr. James corrected him and provided his driver’s license to prove his identity, but the deputy was not convinced. He directed Mr. James to an interview room and detained him for 10 to 15 minutes while Mr. James made phone calls to confirm his identity, his lawyers said.