YouTube last year stopped hiring white and Asian males for technical positions because they didn’t help the world’s largest video site achieve its goals for improving diversity, according to a civil lawsuit filed by a former employee.

The lawsuit, filed by Arne Wilberg, a white male who worked at Google for nine years, including four years as a recruiter at YouTube, alleges the division of Alphabet Inc.’s Google set quotas for hiring minorities. Last spring, YouTube recruiters were allegedly instructed to cancel interviews with applicants who weren’t female, black or Hispanic, and to “purge entirely” the applications of people who didn’t fit those categories, the lawsuit claims.

A Google spokeswoman said the company will vigorously defend itself in the lawsuit. “We have a clear policy to hire candidates based on their merit, not their identity,” she said in a statement. “At the same time, we unapologetically try to find a diverse pool of qualified candidates for open roles, as this helps us hire the best people, improve our culture, and build better products.”

People familiar with YouTube’s and Google’s hiring practices in interviews corroborated some of the lawsuit’s allegations, including the hiring freeze of white and Asian technical employees, and YouTube’s use of quotas.

Mr. Wilberg’s lawsuit, filed in January in California’s San Mateo County Superior Court, alleges that Google discriminated against him for his sex and race, retaliated by firing him when he complained, and in the process violated antidiscrimination laws. Mr. Wilberg declined to comment through his attorney.