Former Pennsylvania Sen. Arlen Specter, a quick-witted but cantankerous presence on Capitol Hill for 30 years, died this morning at age 82 at his home in Philadelphia after losing his fourth battle with cancer, his family confirmed to the Associated Press.

From originating the controversial “single bullet theory” about President John F. Kennedy’s 1963 assassination to accusing Anita Hill of “flat-out perjury” during the 1991 hearings on then-Supreme Court nominee Clarence Thomas, Specter’s storied career as both a lawyer and a politician landed him in the middle of some of the most memorable moments in U.S history.

But he will also be remembered for switching parties in the twilight of his Senate career in an ultimately unsuccessful attempt to secure a sixth term.

Specter’s 30-year tenure in the Senate was spent mainly as a Republican. But he switched to the Democratic Party in April 2009, after it was clear he would likely lose a GOP primary to now-Sen. Pat Toomey. Though Specter often drew tough opponents in both general and primary elections over the course of his career, it was his vote for President Barack Obama’s 2009 stimulus measure that added fuel to the long-simmering resentment of his moderate voting record among Pennsylvania Republicans.

Democrats, including Vice President Joseph Biden and Senate colleagues, also lobbied Specter to make the switch, promising to back him in any Democratic primary fight.

Since his first election to the Senate in 1980, “the Republican Party has moved far to the right,” he said at the time. “Last year, more than 200,000 Republicans in Pennsylvania changed their registration to become Democrats. I now find my political philosophy more in line with Democrats than Republicans.”

Once a court battle ended over a Minnesota Senate seat, Specter’s move meant that Sen. Al Franken (D-Minn.) gave the Democrats a filibuster-proof 60-vote majority for advancing President Barack Obama’s legislative priorities, including his health care law.

Initially, Senate Majority Leader Harry Reid (D-Nev.) said Specter’s seniority would be preserved when he made the switch, but that position drew the ire of fellow Democrats. Senate Majority Whip Dick Durbin (D-Ill.) turned over the reins of a key Judiciary subcommittee to Specter, but the question of his long term seniority in the Democratic Caucus was scheduled to be reviewed at the start of the 112th Congress.

Specter, however, did not make it that far. In an ironic twist, he failed to secure the Democratic nomination, losing the primary to then-Rep. Joe Sestak, who ignored Democratic leaders and refused to clear the field for Specter.

Whether as a Republican or Democrat, “Snarlin’ Arlen” was considered one of the more difficult Senators to work for, with requirements that veered into the obsessive. And he often received questions from the press with the skepticism of a lawyer — parsing journalists’ phrasing to evade or skewer their line of questioning.

“He’s not somebody who will win Miss Popularity or Miss Congeniality, but at the same time, he will win the prize for earnestness and hard work and determination,” then-Sen. Rick Santorum (R-Pa.) told Philadelphia Magazine in 2006.

Specter wasn’t all gruff curmudgeon. His deadpan humor was legendary on the Hill, and after he exited the Senate, he moonlighted as a comedian who was unafraid to take on his old colleagues and other politicians, such as failed GOP presidential candidate Herman Cain.

“Herman Cain has always had a problem with grammar. No matter how hard his teachers tried, they couldn’t convince Herman Cain that harass was one word,” Specter told a crowd at Caroline’s Comedy Club in New York earlier this year, according to Business Insider.

Specter spent most of his young life in Kansas. He graduated from the same high school as former Senate Majority Leader Bob Dole (R). The son of an immigrant from Ukraine, Specter moved quite a bit in his younger years before settling — and becoming a fixture — in Philadelphia.

He was elected district attorney in Philadelphia as a Republican in 1965, even though he had been a Democrat up to that point in his life. He served two terms before losing his bid for a third. Failed election campaigns followed until 1980, when he won the Senate seat being vacated by Richard Schweiker (R).

Specter rose through the ranks on both the Judiciary and Appropriations committees, coming to national prominence during Supreme Court confirmation proceedings in the late 1980s. He opposed President Ronald Reagan’s nomination of Robert H. Bork to the Supreme Court in 1987. Many political watchers speculated that the conservative blowback he received for opposing Bork inspired his forceful defense of Thomas against sexual harassment charges by Hill four years later.

Specter’s aggressive grilling of Hill during the Thomas confirmation hearings infuriated many women, and his treatment of Hill inspired his 1992 Democratic opponent, Lynn Yeakel, to take him on.

In 1995, Specter announced he would run against President Bill Clinton, largely to be a more centrist presence in the GOP nomination fight.

“There are those in our party who would lead us down a different path and squander this unique moment in our nation’s history by using our political capital to pursue a radical social agenda that would end a woman’s right to choose and mandate school prayer,” he said in his announcement speech. But before the primaries even started, Specter was out and had endorsed Dole, the eventual Republican presidential nominee.

Four years later, Specter found himself defending Clinton in an unusual way. During the president’s historic 1999 impeachment trial, Specter refused to vote guilty or not guilty and instead invoked Scottish law by voting “Not proven, therefore not guilty.”

As a young attorney, Specter first made a name for himself working on the Warren Commission, investigating Kennedy’s assassination. He was credited with devising the “single bullet” or “magic bullet” theory, which posited that the same bullet that fatally wounded Kennedy also struck Texas Gov. John Connally. While subsequent inquiries backed up his theory, there remain those who view it skeptically and insist there must have been more than one shooter.

Shortly before winning his Senate seat, Specter served as convicted “Unicorn Killer” Ira Einhorn’s defense attorney in 1979, before Einhorn skipped bail and the country, only to be captured 18 years later in France.

Specter’s health was threatened many times over the years. The most recent occurrence came several years after a very public fight with advanced Hodgkin’s disease, first revealed in February 2005. He underwent chemotherapy while managing, from the helm of the Judiciary Committee, the Supreme Court nomination fights over Chief Justice John Roberts and Justice Samuel Alito.

He eventually went into complete remission for three years. In 2008, he announced he had been diagnosed with a recurrence of the disease and underwent weekly chemotherapy treatments. Earlier in his Senate career, Specter dealt with a brain tumor and a heart condition that required bypass surgery. He was also misdiagnosed with amyotrophic lateral sclerosis, the terminal condition known commonly as Lou Gehrig’s disease, in 1979.

The health battles were featured in his 2008 memoir “Never Give In.” Specter said that health and welfare guided his every move.

“Immediately upon election to the Senate in 1980, I chose to serve on the Appropriations Subcommittee for Labor, Health and Human Services, and Education. I knew that good health was a person’s most important possession. I had played squash virtually every day for a decade,” Specter wrote. “I watched my diet under the close surveillance of my gourmet, calorie-conscious wife.”

Indeed, his own health concerns appeared to fuel some of his legislative goals. For years, Specter was one of the most ardent advocates for increased spending for the National Institutes of Health.

Specter supported Obama’s economic stimulus plan in part because of the funding boost it provided for the NIH. Specter — still a Republican at that point — successfully traded his vote for the bill, which amounted to about a huge boost in the NIH program budget.

In his private life, Specter was an avid squash player, and, as a Senator, was known to ask the State Department to find squash courts for him when he travelled overseas.

He mentioned wanting to return to the squash court in a brief statement issued on Aug. 28, in which he confirmed reports about the recurrence of cancer. In the statement, Specter called the diagnosis “another battle I intend to win.”