MADRID—A former Mexican state governor who once led that country’s ruling Institutional Revolutionary Party was detained here Friday as part of an investigation into money laundering.

Humberto Moreira was detained at Madrid’s international airport on orders from Spain’s Anti-Corruption Office, as part of a probe into money laundering and other offenses, a spokesman for Spain’s National Police said.

Mr. Moreira appeared before a judge of Spain’s National Court, a tribunal that handles high-profile cases linked to terrorism and organized crime. After a late evening hearing, Judge José de la Mata ordered Mr. Moreira imprisoned without bail while the investigation continues, a National Court spokesman said. Spanish prosecutors had told the judge that Mr. Moreira was a flight risk.

Mr. Moreira, who had close political ties to Mr. Peña Nieto, was governor of the Mexican border state of Coahuila from 2005 to 2011. He served as head of the ruling Institutional Revolutionary Party from March 2011 to December of that year, when he resigned amid accusations involving the huge debt his administration had left the state.

Mr. Moreira’s detention is a blow to Mr. Peña Nieto’s ruling PRI party and his government as it underscores the corruption of some top politicians that neither the PRI nor the government has been willing to confront, analysts say.

“It shows how the Mexican government has no desire to catch corrupt politicians and officials even when everybody knows the direct link between corrupt politicians and the ability of drug cartels to operate,” said José Antonio Crespo, an analyst at the CIDE think tank in Mexico City. “It’s up to foreign governments to catch them. I think this will take a lot of the shine from the capture of El Chapo.”

Kent Schaffer, a Houston lawyer who represents Mr. Moreira, said he was aware of Mr. Moreira’s detention but didn’t have any details about it.

Mr. Moreira had been living in Barcelona, moving there after his son, José Eduardo, was found shot to death in Coahuila in 2012. Mr. Moreira said in a radio interview in 2012 that he believed that his son´s murder was ordered by the violent Zetas drug cartel.

Mr. Moreira’s brother, Rubén, is Coahuila’s current governor. A spokesman for the governor declined to comment.

A spokesman from the Mexican attorney general’s office said the Mexican government hasn’t filed charges against Mr. Moreira and that the arrest wasn’t made at its request.

Federal prosecutors in San Antonio charged five men who served under Mr. Moreira’s governorship with laundering tens of millions of dollars through real estate and other transactions. Four of the five, including former Coahuila state finance secretary Hector Javier Villarreal, have pleaded guilty and the fifth is a fugitive from U.S. justice.

Mr. Schaffer, the lawyer for Mr. Moreira, said he had been told by U.S. prosecutors that the U.S. hadn’t requested Mr. Moreira’s arrest and that he wasn’t aware of any indictments of Mr. Moreira in Texas. Federal prosecutors in San Antonio had no comment as to whether Mr. Moreira faces charges there, said spokesman Daryl Fields.

Mr. Moreira, 49 years old, a primary schoolteacher turned politician, rose through the ranks of Mexico’s education ministry before being elected mayor of Saltillo, the capital of Coahuila, in 1999.

His political career reached its zenith when he was elected governor of the coal-rich Coahuila state in 2005. But his tenure was marked by rising indebtedness, which increased almost a hundredfold to about $2.5 billion by 2011, making Coahuila the state with the highest debt per capita in the country.

His years as governor were also marked by a surge in violence as the Zetas drug cartel fought a turf war for control of smuggling routes and the state’s natural resources with their Gulf Cartel rivals.

In March 2011, Mr. Moreira resigned as governor to become head of the ruling PRI party, months before Mr. Peña Nieto won the nomination to become the PRI’s candidate for the 2012 presidential election. But the state’s huge debt load grew into a political scandal, forcing Mr. Moreira to resign as head of the PRI in December 2011.

A spokesman for Mr. Peña Nieto declined to comment. The PRI party said Friday that, although there wasn’t enough information given about Mr. Moreira’s detention, “institutions aren’t responsible for the acts of individuals.”

Mr. Moreira appears as unnamed co-conspirator 1 in a plea agreement last spring for one of his close associates, businessman Rolando Gonzalez Treviño. The plea agreement says unnamed co-conspirator 1 stole “hundreds of millions of dollars” from the state of Coahuila. Part of the money went to buy a network of radio stations in the state.

In recent years, U.S. prosecutors have targeted a number of Mexican governors for crimes including money laundering, drug dealing and racketeering.

Federal courts in south Texas in 2013 indicted Tomás Yarrington, former governor of Tamaulipas state that borders south Texas, on money-laundering and racketeering charges. U.S. prosecutors allege the laundered funds were the proceeds of bribes paid by the Gulf Cartel, a drug-trafficking organization based in Tamaulipas.

Another former Tamaulipas governor, Eugenio Hernandez, was indicted last June in a separate federal court in Texas on money-laundering charges.

Both men both have proclaimed their innocence but remain fugitives.

On Friday, officials from Mexico´s opposition National Action Party praised Mr. Moreira’s arrest but said they regretted that it didn’t happen in Mexico.

“It’s a shame that this is happening abroad and that Mexico isn’t doing its job,” Bernardo González, the PAN’s state leader in Coahuila, said in a radio interview.