A former Customs and Border Protection officer in California has pleaded guilty to running an illegal gun-selling business beginning in the late 1990s, in which he used his status as an officer to buy and sell “off-roster” handguns, federal prosecutors said Wednesday.

Wei Xu, 56, who has been in federal custody since his arrest in February, pleaded guilty to unlawfully engaging in the business of dealing in firearms, unlawfully possessing unregistered firearms, making materially false statements to a federal agency and tax evasion.

He faces a maximum sentence of 25 years in prison when he is sentenced Jan. 14, the U.S. Attorney’s Office for the Central District of California in Los Angeles said.

Xu admitted to selling at least 99 firearms without the required license from the late 1990s until his arrest in February, the federal prosecutor's office said.

In July and August of last year, he sold four guns to an undercover agent who was posing as a buyer, and he sold three of those guns out of the trunk of his car.

"Mr. Xu's public life as a federal officer masked his private greed and disrespect for the law,” U.S. Attorney Nick Hanna said in a statement.

The FBI said in a criminal complaint that Xu had two accounts with a website described as an online marketplace for guns where users can post advertisements, and used that website to arrange for sales to an undercover agent in person.

During one sale in July 2018, Xu showed up in a 2016 Black Maserati Ghibli, and when the undercover agent commented on the car, Xu allegedly said, “I'm like you, playboy,” according to the affidavit in the criminal complaint. He then sold the undercover agent a rifle.

When Xu was arrested, agents found more than 250 firearms, including 41 fully automatic firearms, which were never registered with the federal Bureau of Alcohol, Tobacco, Firearms and Explosives, the U.S. attorney's office said.

In addition to the weapons charges, Xu also pleaded guilty to one count relating to allegations he lied on questionnaires by the Office of Personnel Management to get security clearances.

The U.S. attorney’s office said he was an accounts manager for a China-based auto parts import company and had “near weekly” contacts with associates in the country, but denied having close contacts with foreign nationals or having a foreign financial interest on those forms.

Xu was a watch commander of the Los Angeles and Long Beach Seaport with CBP, and he began working for the customs and border agency in 2004, the FBI said in a criminal complaint.

It wasn't immediately clear late Wednesday when he ended his employment with Customs and Border Protection.

When Xu was arrested, the Associated Press reported that his case was similar to several that prosecutors have brought in the past year against Southern California police officers accused of dealing guns illegally.