It was cable TV and the Internet that made Anthony Weiner into a national figure, endlessly replaying his rants against Republicans over health care. Then, in the last month, it was the same media that helped destroy him — alarming top Democrats by endlessly replaying a series of lewd photos that he had sent women online.

In response, party leaders mounted an effort against Weiner with an intensity that surprised many on Capitol Hill. They issued coordinated statements, made coordinated TV appearances, and set up a meeting Thursday to strip Weiner of his coveted committee assignments.

Finally, the pressure campaign worked.

On Thursday, Weiner announced his resignation in his district in Brooklyn. As a heckler shouted insults from the back, Weiner said he was leaving because of “the distraction that I have created.”

“I am here today to again apologize for the personal mistakes I have made and the embarrassment I have caused,” Weiner said, reading from a statement at the senior center where he had announced previous campaigns for the City Council and Congress.

His departure leaves an empty seat in Washington and a debate in New York about whether the district should be eliminated altogether as part of the redistricting process. For his party, his departure allows Democrats to return to their campaign against Republican plans to overhaul Medicare.

And it signals the limits of the fire-breathing model Weiner used to stand out in a crowded political world. After a career playing to an audience beyond the halls of Congress, it seemed that his departure would have little impact on the body he left.

“That’s an inside story,” Sen. Patty Murray (D-Wash), chairman of the Democratic Senatorial Campaign Committee, said about the Weiner escapade. “That’s not what I’m hearing about at home. It’s not what our candidates are hearing.”

Weiner’s undoing began three weeks ago, when he posted a photo of his underwear-clad groin on his public Twitter feed. He at first blamed the photo on a “hacker,” but then confessed after more photos appeared, all showing Weiner posing suggestively for women he had met online.

Ultimately devastating for him, Weiner’s mistake also came at an inopportune time for his party. Democrats had just won a special election in New York — ironically, set off by another congressman who had sent a suggestive photo to someone he met online — and wanted to continue hammering the message that Republicans wanted to “destroy” Medicare.

Lawmakers and aides said the most damning thing Weiner did was telling the tale about an alleged hacker: He lied, day after day, to his friends in Congress and to a national TV audience.

Had he admitted fault right away, “I think it would have helped him with his colleagues,” said Rep. Bill Pascrell Jr. (D-N.J.), a close friend of Weiner’s. “I think that it could have ended differently.”

Last week, after his confession, House Minority Leader Nancy Pelosi (D-Calif.) spoke almost every day with Weiner, as had Rep. Steve Israel (D-N.Y.), chairman of the Democratic Congressional Campaign Committee. Both, aides said, were steadily trying to “get him to the place” where he would announce his retirement on his own.

But Weiner didn’t get to that place.

Instead, Democratic aides said, he told Pelosi about polls showing that a majority of voters in his district supported him. All the more reason to go, Pelosi said: “Consider those rose petals, to let you go graciously,” the aide said. By late last Friday, Weiner said he would leave for counseling instead.

Pelosi upped the ante. She issued a statement Saturday, calling publicly for him to go. It was followed quickly by one from Israel and Rep. Debbie Wasserman Schultz (D-Fla.), chairman of the Democratic National Committee.

A group of Weiner’s friends in Congress objected and confronted Pelosi on Tuesday. Their complaint, participants and aides said, was that Weiner had been “thrown under the bus” without being found guilty of ethics violations.

Weiner’s friends saw a contrast between Pelosi’s treatment of Weiner and her treatment of Rep. Charles B. Rangel (D-N.Y.). Pelosi allowed Rangel to remain chairman of the tax-writing Ways and Means Committee for 18 months while he was under an ethics investigation — which ultimately led to him being found guilty of 11 ethics violations related to personal finances.

“Isn’t it interesting,” Pascrell said Thursday, “that there’s always something more mysterious about flesh than there is about cash.”

But by Wednesday, Weiner had made his decision. That night, Israel was at a White House picnic for members of Congress when his BlackBerry rang. It was Weiner. He was resigning.

Israel told him to hold on for a minute.

The Long Island Democrat walked across the White House lawn to find Pelosi and handed her the phone. Weiner told Pelosi the same thing.

On Thursday, he told everybody else.

“I make this apology to my neighbors and my constituents, but I make it particularly to my wife, Huma.” Weiner’s pregnant wife, Huma Abedin, a top aide to Secretary of State Hillary Rodham Clinton, did not appear with her husband as he made his announcement.

Political observers said that Weiner’s scandal is unlikely to change the course of the 2012 elections: It is not part of broader wrongdoing among Democrats, they said, and is likely to be long forgotten by then.

In the short term, Weiner’s resignation triggers a special election to fill his seat, which stretches across the outer sections of Brooklyn and Queens. New York Gov. Andrew M. Cuomo (D) will be charged with calling for that election.

Political observers say the seat leans Democratic. But this special election could have special complications. New York needs to cut two congressional seats in the redistricting process, and state legislators might choose to eliminate Weiner’s seat. That would allow them to give his territory to incumbents nearby.

So the state’s Democratic power brokers may need somebody ambitious enough to win the seat — and then selfless enough to give it up.

On Thursday, even as he announced his resignation, Weiner seemed unwilling to concede that his career is over. In his speech, he extolled his upbringing, as the son of a mother who was a schoolteacher and a father who attended law school on the G.I. Bill. He talked up his constituents and his work on their behalf.

The words sounded like those of someone at the start of a political career, not its shame-faced end.

“I had hoped to be able to continue the work that the citizens of my district elected me to do: to fight for the middle class and those struggling to make it,” Weiner said.

But, as Weiner announced his resignation, a heckler cheered and shouted, “Bye, bye, pervert!”

The TV cameras picked that up, too.

Staff writers Chris Cillizza, Karen Tumulty and Felicia Sonmez contributed to this report.