Representative Mike Lawler, a Republican in a crucial New York swing district, and Cait Conley, his Democratic challenger, sparred in a debate on Monday over President Trump’s policies and their records, as well as hot-button issues like data centers and energy costs.

The debate, which took place in the afternoon and aired later on News12, was the first time that Mr. Lawler and Ms. Conley had appeared onstage together during the campaign. Ms. Conley used the moment to highlight her decades of military service, while Mr. Lawler sought to burnish his bipartisan bona fides by sharing examples of how he had worked with Democrats in Washington.

But more than anything else, the two candidates attacked each other, with Ms. Conley seeking to portray Mr. Lawler as a lackey of Mr. Trump while Mr. Lawler characterized his opponent as a carpetbagger.

Ms. Conley, a combat veteran and a national security expert in the Biden administration, beat two opponents who ran to her left in the June primary. Since then, Mr. Lawler and his allies have focused on her work for a company that built anti-drone systems and another that used artificial intelligence to scrape public sources for law enforcement analysis.

At Monday’s debate, Mr. Lawler said Ms. Conley’s professional history — and her unwillingness to describe the specifics of her work, citing nondisclosure agreements — was emblematic of an ethically murky culture in Washington.

“You left the Biden administration to get a private sector job with big A.I. and big tech to the tune of hundreds of thousands of dollars,” Mr. Lawler said, “only to move up here two months after you got the contract.”