To counter Mr. Putnam, Ms. Granger secured the coveted endorsement of Mr. Trump and energized her campaign operation, lining up endorsements from anti-abortion rights groups like the Susan B. Anthony List and high-ranking colleagues including Representative Liz Cheney of Wyoming, the No. 3 Republican, to help her raise campaign money.

In interviews with more than two dozen district officials, Texas strategists and voters, Ms. Granger was widely viewed as having the upper hand with her high name recognition and an extensive record of securing projects for her district, which includes a large presence by the military contractor Lockheed Martin, a joint reserve base and other defense priorities. But, they acknowledge, Mr. Putnam has mounted a formidable challenge — and some voters are drawn to a new candidate.

While Ms. Granger is a lifetime Fort Worth resident, Mr. Putnam recently moved from Colleyville, a smaller Dallas and Fort Worth suburb outside the 12th District, where he served three years on the City Council. Mr. Putnam could have run for Congress there; Representative Kenny Marchant, the Republican who has served there since 2005, has announced he is retiring. But that district is far less conservative, and Mr. Putnam, who now lives at a property in Fort Worth and attended college there, said he felt he was a better fit for Ms. Granger’s district.

For now, Mr. Putnam and his allies are working to turn Ms. Granger’s long legislative record against her. While Mr. Putnam is supported by anti-spending activists, one of his principal criticisms of Ms. Granger is that she has not secured enough federal money for the border wall that is Mr. Trump’s signature campaign promise.

Mr. Putnam told voters at an event last month that Mr. Trump had endorsed Ms. Granger only because of “the politics of impeachment.” He noted that the president had tweeted his support for the congresswoman on the eve of the House vote on articles of impeachment to ensure Ms. Granger would stick with him and vote against the charges. (She did, along with every other House Republican.)