In Pennsylvania, he reiterated that he had been sarcastic, but added: “Not that sarcastic, to be honest with you.”

Republicans often complain about the national news media, arguing that most reporters and publications are tilted against them. In the 1992 presidential race, Republicans even produced a bumper sticker urging voters to “annoy the media” by re-electing President George Bush. And in his 2016 primary campaign, Senator Marco Rubio of Florida accused the press of being the equivalent of a “super PAC” for Democrats.

On the Democratic side, Senator Bernie Sanders of Vermont fulminated this year about the “corporate media,” which he described as hostile to liberal ideals. And aides and supporters of Mrs. Clinton routinely complain that reporters treat her unfairly.

But the Trump campaign has made accusations of news media bias a pervasive theme, and has attacked publications and reporters with virulence. Since last year, Mr. Trump has made a practice of riling up his crowds with mockery of the media, often pointing to the press risers and describing reporters as dishonest.

In Erie on Friday, his audience jeered each time Mr. Trump mentioned a news outlet, and at one point many in the crowd turned their backs on him to face the press and express their contempt with a variety of shouts and gestures. “Dinosaur media is failing!” one man yelled.

Mr. Trump’s slashing attacks have generated embarrassing scenes for his campaign, as agitated Trump fans have acted on his goading. On Thursday night, video circulated widely online of an angry Trump supporter berating reporters and making an obscene gesture in their direction in Kissimmee, Fla. In one instance during the primaries, Katy Tur, a reporter for NBC News, reported she was escorted to her car by the Secret Service after a rally in which Mr. Trump assailed her by name.

If bashing the media proved an effective way of rallying the Republican base to his side during the primaries, Mr. Trump must now prove himself to a broader community of voters in the general election, who are far less preoccupied with the notion of press bias. Republican strategists see Mr. Trump’s offensive mainly as an exercise in thin-skinned defensiveness, rather than a shrewd political strategy.