F0rmer housing secretary Julián Castro, who was also the only Latino candidate in the Democratic primary, said Thursday he would end his bid for the presidency, capping a yearlong campaign where he struggled in polls but remained a policy pacesetter on immigration and fighting poverty.

Throughout his campaign, Mr. Castro, 45, a native of San Antonio who spent five years as its mayor, portrayed himself as an unapologetic liberal who was shaped by his humble beginnings and had been overlooked by the press. Though he created some memorable moments as he championed progressive policy and challenged his rivals on the campaign trail, Mr. Castro failed to catch on with voters and was unable to break into the upper tier of a crowded primary field. His exit is the latest departure of a candidate of color from a field that began as the most racially diverse ever in a Democratic primary.

“I’ve determined that it simply isn’t our time,” Mr. Castro said in a nearly four-minute video message released by his campaign, which included a montage from his year on the trail, including visits to the border and a homeless encampment in Oakland. “Today it’s with a heavy heart, and profound gratitude, that I will suspend my campaign for president.”

“I’m not done fighting,” Mr. Castro continued, though he gave no indication of his immediate plans. “I’ll keep working towards a nation where everyone counts, a nation where everyone can get a good job, good health care and a decent place to live.”

The video also features Mr. Castro listing the names of African Americans and Latinos who were killed by police or died in police custody in recent years, something he did often during debates and on the trail.

Mr. Castro’s departure shrinks the field of Democratic candidates to 14. He was viewed as a potential vice presidential pick by Hillary Clinton in 2016 and could be a valuable running mate this year, with Democrats eager to court Latino voters.

One of the most high-profile Latino Democrats ever to seek the party’s nomination, Mr. Castro left his stamp on the national conversation about border control and immigration reform. His memorable confrontation with former Representative Beto O’Rourke — a fellow Texan — during the first Democratic debate in June led to a broad discussion about whether to decriminalize border crossings, as Mr. Castro had suggested. Almost instantly, Mr. Castro’s progressive stance on the issue became a litmus test among Democrats seeking the nomination, and several candidates ultimately embraced his position.

Mr. Castro, whose keynote address at the 2012 Democratic National Convention rocketed him onto the national stage, also carved out substantive positions on core issues like housing, education, criminal justice and the economy, while developing unique and specific proposals on police reform, strengthening indigenous communities, protecting animals and eliminating lead poisoning.

He espoused the benefits of universal prekindergarten, which he had instituted in San Antonio when he was mayor, and proposed taxing the inherited wealth held by the country’s top earners. And his relentless focus on how to help the poor — encapsulated by a plan to end hunger — won him support from those who saw him as a fierce advocate for the underserved and underrepresented.

But Mr. Castro never developed much enthusiasm among voters and did not find his footing in the polls, rarely exceeding 2 percent support in national or early-voting state surveys. Although he participated in the first four primary debates, he did not make the cut for those that followed. Weeks before the qualification deadline for the November debate, he warned that if he could not raise more money, he would end his campaign. Although he raised more than $800,000, meeting the goal he had set, he never got the polling boost he needed.

The absence of Mr. Castro’s voice from the debate stage was widely noted, and he gained attention in recent weeks with his call for a reordering of the Democratic primary schedule, arguing that Iowa and New Hampshire, whose largely white populations vote first, did not represent the demographics of the country.

He was outspoken when Senator Kamala Harris of California made a surprise exit from the race in early December, saying that “Kamala was treated very poorly” and had been “held to an unfair standard” by the media.

“The media’s flawed formula for “electability” has pushed aside women and candidates of color,” he said that day on Twitter. “Our party’s diversity is our strength.”

For some, Ms. Harris’s departure bolstered the case Mr. Castro had been making about the primary system. On the day she announced she was dropping out, Mr. Castro had his best fund-raising day of the quarter.

Mr. Castro’s concerns about the field’s diminishing diversity were amplified again in the days leading up to the December debate, when nine of the Democratic candidates, including Mr. Castro, signed a letter to the D.N.C. asking officials to lower the thresholds to qualify for the party’s January and February events. The letter noted that many of the candidates who had helped make the Democratic field diverse had been “excluded.” And indeed, the December debate featured six white candidates and only one person of color, the businessman Andrew Yang.

Shortly after Mr. Castro made his announcement, other candidates expressed their disappointment at his departure and gratitude for his contributions.

“Your voice and campaign were invaluable in sticking up for underrepresented communities and pushing the field forward,” said Senator Cory Booker of New Jersey. Senator Elizabeth Warren of Massachusetts praised Mr. Castro’s “powerful voice” and “bold and progressive plans.”

Mr. Castro, a third-generation Mexican-American who has endured repeated scrutiny over his lack of Spanish fluency, ended his last campaign video with a message to supporters:

“Ganaremos un día!” The translation is offered only in the subtitles: “One day we’ll win!”