Former President Donald Trump named Sen. J.D. Vance of Ohio as his running mate, ending months of theatrical buildup and settling on a much younger partner who could help appeal to working-class voters in critical Midwest battleground states .

If Trump is elected, Vance, who turns 40 in August, would be one of the youngest vice presidents in history and one with just two years of elected experience. But he is a figure closely associated with the style and views of Trump’s conservative, populist movement .

Given how closely Vance aligns with Trump, he could be less effective with independents and moderate Republicans.

The announcement came as the Republican National Convention in Milwaukee, where Trump and Vance will formally accept the party’s nomination, was under way, setting the stage for a four-month blitz to the Nov. 5 election.

The pick comes amid widespread calls for unity following the assassination attempt at Trump’s rally in Pennsylvania on Saturday, when a gunman opened fire on the crowd. Trump said he suffered a gunshot wound to his ear. One rally-goer was killed and two others were critically wounded. The gunman was fatally shot by a Secret Service sniper.

While the GOP came a step closer to solidifying its ticket, the Democrats are still scrambling over theirs. Biden is straining to quell tremendous pressure on him to withdraw from the race following his disastrous June debate , which exacerbated voter concern over his age and fitness for office. Biden, 81, has insisted he will remain at the top of the ticket, along with his running mate, Vice President Kamala Harris , leaving many Democrats worried about the prospects in November.

The latest Wall Street Journal poll showed Trump, 78, opening a 6-point lead over Biden among voters nationally, with 80% saying that the president is too old to run for a second term—up from 73% in February. Trump also has held persistent although sometimes slight leads in battleground states likely to decide the outcome.

For months, a dozen or so leading contenders for the job had made public auditions for Trump. Many, including Vance, defended him on national television, showed up to court with him for his Manhattan criminal case and touted ties to major donors.

The list was diverse by race, gender and geographic location. Toward the end, Vance, North Dakota Gov. Doug Burgum and Sen. Marco Rubio of Florida emerged as front-runners, separating from the likes of Sen. Tim Scott of South Carolina, Rep. Elise Stefanik of New York and former Housing and Urban Development Secretary Ben Carson.

Trump went with Vance, the one most representative of America First populism and a potential heir to Trump’s Make America Great Again movement. Trump was impressed by his credentials: service in the Marines, a Yale Law School degree and ties to wealthy Silicon Valley donors.

In Vance, Trump gains a loyalist seen as an effective messenger. Vance came to national prominence with his memoir, “Hillbilly Elegy,” about growing up in working-class America. He was once a vehement critic of Trump but now says he was wrong.

Vance later worked in venture capital in San Francisco, where he formed relationships with technology entrepreneurs. Vance has helped bring some of them closer to Trump.

Vance in 2022 won a U.S. Senate seat representing Ohio—thanks in good part to a Trump endorsement. He has cut a staunchly populist profile in Washington, railing against foreign engagement and trade deals. And he has formed a friendship with Donald Trump Jr., which gave him an inside track in the selection process.

Supporters say Vance could help Trump double down on his dominance with white working-class voters, especially in the “blue wall” states of Wisconsin, Michigan and Pennsylvania, which helped propel Biden to victory in 2020.

Despite his full embrace of MAGA, Vance has taken some bipartisan steps in office, including work with Democrats on railroad-safety legislation in the aftermath of a train derailment in East Palestine, Ohio, and supporting policies aimed at the working class.

Trump has said he wants a running mate who won’t make mistakes, looks the part and will help him win. He has also said he doesn’t think the running mate factors much into voter choices.

“The first quality has to be somebody that you think will be a good president because if something should happen, you have to have somebody that’s going to be a great president,” Trump said on Fox News in February.

In 2016, Trump waited three days before the GOP convention to officially announce Mike Pence as his running mate, a choice meant to bolster him with Midwestern and evangelical voters, a core of the party’s conservative base.

Pence was the opposite of Trump’s flamboyant style but proved himself a reliable lieutenant until he rejected Trump’s attempts to pressure him into helping stop Congress from certifying Biden’s win the day of the Jan. 6, 2021, riot at the Capitol. Pence hasn’t endorsed Trump’s re-election bid.

Write to Alex Leary at alex.leary@wsj.com and Vivian Salama at vivian.salama@wsj.com