President Trump threw his political clout behind a hard-line candidate in the contested primary for governor of Georgia on Wednesday, backing Brian Kemp, a state official who has run television ads showing him wielding a shotgun and vowing to “round up” illegal immigrants.

Mr. Trump’s support could well decide a close nomination fight between Mr. Kemp and Casey Cagle, Georgia’s Republican lieutenant governor. The two men are competing in a July 24 runoff election after neither managed to win a majority in the first round of voting in May.

The eventual Republican nominee will compete in the general election in November against Stacey Abrams, a former Democratic leader in the Georgia House of Representatives who is vying to become the first black woman to serve as governor of a state.

A contest between Mr. Kemp, Georgia’s secretary of state, and Ms. Abrams would likely be one of the most hotly contested in the country, and it could represent an important cultural test for a traditionally conservative state that has grown more diverse and cosmopolitan in recent years. Mr. Trump won Georgia in 2016 by a clear, but not overwhelming, margin, and Democrats believe it could be a swing state in 2020.