MIAMI — Rep. Ron DeSantis of Florida said Monday he has resigned from Congress to devote himself to running for governor in one of the nation’s most closely watched midterm election contests.

DeSantis, a Republican, is locked in an intense battle with Mayor Andrew Gillum of Tallahassee, the Democratic nominee.

In a letter to House Speaker Paul Ryan, DeSantis cited his likely absences for the rest of the congressional term as a reason to step down.

‘‘Under these circumstances, it would be inappropriate for me to accept a salary,’’ he wrote. He made his resignation retroactive to Sept. 1. ‘‘This is not a decision I make lightly,’’ he said.

DeSantis, a three-term congressman from a district that includes the Daytona Beach area, routed the state’s agriculture commissioner, Adam Putnam, in the Florida primary two weeks ago. The Republican race was defined by President Donald Trump’s endorsement of DeSantis, a loyal acolyte.

Republicans in Washington said that, with the congressman’s seat set to be filled in the November general election, there would almost certainly not be a special election to fill the vacancy. Running to replace him in the GOP-leaning seat are Republican Michael Waltz and Democrat Nancy Soderberg.

DeSantis’ decision was aimed in part at denying Gillum and Democrats ammunition about his missing votes. The Republican was absent for all 14 votes on the House floor last week and likely would have missed dozens more between now and the election.

A Quinnipiac poll last week, one of the first public surveys taken since Florida’s Aug. 28 primary, showed a highly competitive race. Gillum drew 50 percent from likely voters while DeSantis was taking 47 percent.