WASHINGTON (Reuters) - Arlen Specter, a gruff, independent-minded moderate who spent three decades in the U.S. Senate but was spurned by Pennsylvania voters after switching in 2009 from Republican to Democrat, died on Sunday of cancer, his family said. He was 82.

NBC's Andrea Mitchell talks to Msnbc's Alex Witt about former Pennsylvania Sen. Arlen Spector who died from complications of non-Hodgkins Lymphoma.

Specter had announced in August a recurrence of non-Hodgkin lymphoma, cancer of the lymphatic system. His son Shanin Specter confirmed his death.

Resilient, smart and aggressive, the former prosecutor frequently riled conservatives and liberals on his way to becoming Pennsylvania's longest-serving U.S. senator. He was elected to five six-year terms starting in 1980. He left the Republican Party because he said it had become too conservative.

Former Pennsylvania senator Arlen Specter dies of cancer at his home in Philadelphia. He was 82. Msnbc's Alex Witt talks with The Daily Beast's Eleanor Clift and Politico's Rachel Smolkin.

Specter steered a moderate course during an era when the two major U.S. political parties became increasingly polarized, and often broke with his party. His sometimes testy demeanor and opportunistic maneuvering earned him monikers like "Snarlin' Arlen" and "Specter the Defector."

In 2009, Specter left the Republican Party after 44 years when he concluded he could not win his party's primary in Pennsylvania in 2010 against a conservative challenger. But his bid for re-election in 2010 ended in failure when he was beaten by a liberal challenger for the Democratic nomination.

Chris Maddaloni / CQ-Roll Call Photos Former Sen. Arlen Specter prepares to testify at a Senate Judiciary Administrative Oversight and the Courts Subcommittee hearing on "Access to the Court: Televising the Supreme Court."

After President John Kennedy's assassination in 1963, Specter served on the Warren Commission that investigated the shooting, and he helped devise the disputed "single-bullet" theory" that supported the idea of a lone gunman.

During his lengthy Senate career, Specter was crucial in increasing U.S. spending on biomedical research.

He helped get one conservative, Clarence Thomas, confirmed as a Supreme Court justice in 1991, while torpedoing the Supreme Court nomination of another conservative, Robert Bork, in 1987. He infuriated liberals during the Thomas confirmation hearings with prosecutorial questioning of Anita Hill, a law professor who had accused Thomas of sexual harassment. At one point, Specter accused her of "flat-out perjury."

Specter annoyed fellow Republicans by voting "not proven" on impeachment charges against President Bill Clinton in 1999, helping prevent the Democrat from being ousted from office over his affair with a White House intern.

Specter unsuccessfully sought the 1996 Republican presidential nomination. He had several health scares, undergoing open-heart surgery and surgery for a brain tumor, as well as chemotherapy for two bouts of Hodgkin's lymphoma.

In February 2009, a month after Democratic President Barack Obama took office, he became one of three Republican senators to vote for Obama's economic stimulus bill that Specter said was needed to avert a depression like that of the 1930s.

Specter was reviled by some conservatives for giving Obama an important early political victory. In April 2009, Specter at age 79 abandoned the Republicans - saying his party had moved too far to the right - and was welcomed by Obama and Vice President Joe Biden as a Democrat.

Incumbent senators rarely face stiff challenges for their party's nomination for re-election, but Specter barely survived conservative Pat Toomey's challenge in 2004. Pennsylvania Republican primary voters are more conservative than the state's overall electorate, and Specter calculated that he could not win the Republican primary in 2010.

"I am not prepared to have my 29-year record in the United States Senate decided by the Pennsylvania Republican primary electorate - not prepared to have that record decided by that jury," Specter said in April 2009 in explaining his defection.

In the 2010 Democratic primary, Specter had the support of the Democratic establishment, including Obama, Pennsylvania's governor and labor unions. But liberal challenger Joe Sestak, a retired Navy admiral and two-term congressman, painted Specter as a political contortionist concerned only about himself.

A Sestak TV ad featured a clip of Specter telling a news interviewer: "My change in party will enable me to be re-elected." Sestak thumped Specter in a May 2010 primary.

"He has been a serious and consequential senator for three decades, yet mostly ungenerous words come to mind: driven, tenacious, arrogant, self-righteous, opportunistic," Congress expert Thomas Mann of the Brookings Institution think tank told the New York Times after Specter's defeat.

Specter was born in Kansas in 1930 during the Great Depression. His father was a Russian Jewish immigrant who owned a junkyard. Specter moved to Philadelphia at age 17 to attend the University of Pennsylvania. He graduated in 1951, then served in the Air Force before attending Yale Law School.

He was a Democrat until age 35, when the Republicans offered their nomination for district attorney of Philadelphia. He served as the city's district attorney from 1966 to 1974.