MEXICO CITY (AP) _ The government said U.S. narcotics agent Victor Cortez Jr. overstepped the strict bounds set for American drug police operating in Mexico and that authorities were justified in detaining him earlier this month.

Responding to a U.S. protest over the incident made on Aug. 18, the Foreign Ministry said in a diplomatic note made public Wednesday that police in Guadalajara had detained Cortez ''to establish his identity and clarify his conduct.''

The United States claims that the 34-year-old Drug Enforcement Administration agent was ''illegally detained, interrogated and tortured'' with electric shots while he and a man identified as a DEA informant were in custody Aug. 13 in Mexico's second largest city.

On Tuesday, the Attorney General's office charged 11 Jalisco state policemen with abusing their authority and injuring Cortez. The Attorney General's office asked a criminal court judge in Guadalajara to order their arrest.

Mexico's response to the U.S. protest mentioned the charges filed against the policemen and a medical report that said Cortez suffered bruises on the stomach and right shoulder, but complained about his conduct and cited government limitations on DEA activity in Mexico.

Although Cortez had been issued consular credentials at the request of the U.S. Embassy, he was not carrying them at the time of his detention and ''was engaged in activities that are obviously and evidently unrelated to the consular function,'' the Mexican note said.

It said he was ''in the company of a person known for his criminal background (Antonio Garate Bustamente) and that (who), according to Mr. Cortez' own declaration, was his collaborator.''

Garate Bustamente, a Mexican, has been identified as a DEA informant.

In addition, Cortez was driving a car with license plates belonging to another vehicle and ''had in his possession prohibited weapons,'' among them a semi-automatic rifle and a 9mm submachine gun, weapons that can legally be used only by the Mexican military, the note said.

''Certainly, it is of concern to the government of the United States as it is to the government of Mexico that officials of the Drug Enforcement Administration ... engage in functions unrelated to those for which they have been authorized,'' the Foreign Ministry note said.

It said Mexico, at U.S. request, allows DEA agents as part of embassy or consular personnel so they can engage ''in strictly limited activity, that is, the exchange of information with Attorney General's office authorities on the combat of narcotics trafficking, a task of interest to both sides.''

The note did not elaborate on how such information is to be gathered.

In Washington, State Department spokesman Charles Redman said the start of legal proceedings against the Jalisco policemen was a ''positive development.''

He said Cortez suffered ''brutal torture'' and the United States is ''ready to assist Mexican authorities in moving expeditiously to bring to justice those responsible.''

U.S. protests over the case led to an outcry from senators and deputies from both the ruling Institutional Revolutionary Party and opposition parties who demanded an explanation for the DEA presence in Mexico.

Senate leader Antonio Riva Palacios was quoted as saying Mexico should ''reject any attempt to infringe on its sovereignty.''

The U.S. Embassy has said DEA agents serve as a liaison between U.S. and Mexican agencies combatting drug traffic and do not carry out detentions or arrests.

The Mexican note mentioned testimony from four men who were detained at Jalisco state judicial police headquarters at the time. However, it did not say, as an Attorney General's office statement did on Tuesday, that they ''had knowledge of the bad treatment'' of Cortez by police.

The charges against the policemen were filed Tuesday with the same Jalisco state judge, Oscar Vazquez Marin, who ordered last year that two reputed drug barons be tried in the February 1985 kidnapping, torture and slaying of DEA agent Enrique Camarena Salazar in Guadalajara.