President Trump's new pick for labor secretary spoke out against anti-Muslim discrimination in testimony to Congress six years ago.

In a speech to the Senate Judiciary Committee, Alexander Acosta praised efforts by President George W. Bush's administration to protect American Muslims.

Acosta led the Justice Department's civil rights division for two years under Bush. In 2011, after he left government and while he was dean of the Florida International University law school, he testified at a Senate hearing on protecting the civil rights of Muslims.

He said federal attorneys investigated more than 600 "backlash" incidents between 2001 and 2005, resulting in more than 170 prosecutions.

Related: Trump announces Alexander Acosta as labor secretary pick

Acosta also said informal meetings between Muslim American and Arab American community leaders and government agencies "worked well."

"These efforts following 9/11 were important. They set a tone," Acosta told the committee. "They reminded those who might be tempted to take out their anger on an entire community that such actions were wrong."

As labor secretary, Acosta would serve a president who once pledged to suspend all Muslim immigration, and whose ban on travel by citizens of seven predominantly Muslim countries has been overturned by the federal courts.

Trump tapped Acosta on Thursday as his nominee to lead the Labor Department. His original choice, Andrew Puzder, withdrew his candidacy on Wednesday after several Republicans said they wouldn't support him.

Related: Andrew Puzder withdraws as labor secretary nominee

Unlike Puzder, a fast food executive, Acosta has spent much of his career in public service. He served on the National Labor Relations Board from 2002 to 2003 under Bush, and was the first Hispanic assistant attorney general at the Justice Department.

Acosta remains dean of Florida International University's law school.

Acosta handled a number of discrimination cases at the Justice Department. In 2004, his office intervened on behalf of an 11-year-old Muslim girl who was suspended from public school in Oklahoma for wearing a headscarf.

"No student should be forced to choose between following her faith and enjoying the benefits of a public education," Acosta said at the time.

He said while local schools have the authority to set dress standards, those rules "cannot come at the cost of constitutional liberties." The school district settled a Justice Department lawsuit, allowed her to wear the headscarf and pledged to change its dress code.

Acosta's department also settled a racial discrimination lawsuit against Cracker Barrel in 2004.

Federal officials accused the restaurant chain of allowing white servers to refuse to wait on black customers and segregating customers by race.

Cracker Barrel agreed to enact "far reaching changes to policies and practices to prevent discrimination."