Democratic presidential candidate Beto O’Rourke speaks during a town hall event at Upstate Circle of Friends in Greenville, South Carolina, in June 16.

MIAMI — In his months on the campaign trail, Beto O’Rourke has wanted to make one thing explicitly clear: He is not a pendejo.

Never mind whether anyone in the audience understands the Spanish slang for idiot, it is now a standard part of his stump speech: “We don’t want our kids looking back at us 40 years from now and saying, ‘Who were those pendejos?’ ”

During the first Democratic presidential debate, O’Rourke eagerly brought his Spanish to prime time.

“Necesitamos incluir cada persona en nuestro democracia,” he said, responding to a question about taxes with a riff on inclusion, roughly translated as: “We must include every person in our democracy.”

Sen. Cory Booker of New Jersey jumped in to show that he, too, could communicate in Spanish, which he had picked up mainly from language classes in Mexico and Ecuador. Pete Buttigieg, mayor of South Bend, Indiana, has made it known he speaks not just Norwegian, but Spanish as well, conducting bilingual interviews on Telemundo.

Then there is Julián Castro. He ended the second debate by declaring: “Me llamo Julián Castro, y estoy postulando por presidente de los Estados Unidos.”

With imperfect grammar, Castro reminded Spanish speakers exactly who he is: the grandson of a Mexican immigrant who was raised speaking English in a Latino-majority city.

At campaign events, Castro often leaves out Spanish. His relationship with the language, he has said, is somewhat fraught. He has taken lessons, but he can still appear uncomfortable speaking Spanish in large crowds or off the cuff.

In this way, he’s representative of many Latino voters. Only 13% of Latinos who are currently registered to vote in the United States speak Spanish as their primary language, according to the Pew Research Center.

So, then, who is all this campaign-trail Spanish for?

More than 40 million people in the United States speak Spanish, making it the second-most spoken language in the country behind English. But the history of Spanish in the United States, and who feels comfortable speaking it publicly, is complicated. Castro’s biography illustrates some of the complexity.

As a child, he often accompanied his mother, a prominent Chicana activist, to political meetings and protests. She told him stories of how she had been shamed and forcefully told not to speak Spanish. While he heard the language on television and from his grandparents, he rarely spoke it. When Castro was elected to the San Antonio City Council, he sought out a private tutor.

“There is an irony,” he said in an interview. “There’s a greater expectation, because I’m Latino, of speaking Spanish. Many folks outside of second or third generation Latino communities are not aware of the history of the attempts to eradicate the Spanish language from families.”

Even as the Latino population in the United States continues to grow, and a majority of those who are parents now speak Spanish to their children, Latinos tell pollsters that they don’t view Spanish as essential to the culture.

About 28% say Spanish skills are a requirement for someone who identifies as Latino, according to Pew. A recent poll by UnidosUS, a Latino advocacy group, showed that a candidate’s ability to speak Spanish was last on a list of Latino voters’ priorities, well below “values diversity” and “willing to work with both parties.”

None of that has stopped O’Rourke. Even when it is unclear a crowd has any Spanish speakers, he toggles between English and Spanish.

During a recent trip through South Carolina, O’Rourke displayed his Spanish at nearly every campaign stop, which did resonate with some voters. After a forum in Sumter, where Hispanics make up about 3% of the 40,000 residents, one woman rushed over to thank him. She said he was the first politician she had heard speak Spanish since she immigrated from Mexico nearly 20 years ago.

Both O’Rourke and Castro are Texas natives who have made immigration and their experiences along the Mexican border central aspects of their campaigns. Their relationships with Spanish have also shaped their political identities and the ways they appeal to voters.

O’Rourke can casually speak Spanish in a manner that people at his events find charming. Castro is often under greater scrutiny, frequently asked why he is not fluent. He has also been careful not to portray himself as a candidate who caters to only Hispanic voters.

Buttigieg and Booker sharpened their Spanish skills with local media as mayors and often prepared for interviews by asking staff members to scribble down Spanish translations for words such as “contraception” or “generational change.”

“I find there’s a tremendous amount of appreciation, if you show that you put in the work,” Booker said in an interview. “There’s gratitude and this incredible generosity.”

Native Spanish speakers do, of course, evaluate the candidates’ efforts. After the debates, The Miami Herald assigned a grade to everyone who tried. O’Rourke received the highest: B.

“If you are going to butcher the language, you are better off sticking to English,” said Arturo Vargas, chief executive officer of the National Association of Latino Elected and Appointed Officials. The group hosted a presidential forum in Miami in June in which eight candidates spoke to several hundred people.

Privately, Castro has seethed over the scrutiny of his Spanish. In 2016, he strongly denied a report in The New York Post’s gossip pages that he was “cramming with Rosetta Stone,” while Hillary Clinton was mulling her potential running mate. Ultimately, she chose Sen. Tim Kaine of Virginia, who is bilingual.

After the second debate, Mayor Bill de Blasio of New York City showed up at the Miami airport to support workers on strike there. Holding a microphone, he enthusiastically shouted one of the best-known sayings in Latin American history: “Hasta la victoria siempre!”

It’s a phrase popularized by Che Guevara, an Argentine guerrilla who helped Fidel Castro lead a communist revolution in Cuba. Hundreds of thousands of people fled the regime, many to South Florida — where few historical figures are more despised than Castro and Guevara.

Responding to the instant backlash, de Blasio issued an apology within hours, saying he did not know the history and only meant the words literally: “Until victory always.”