Joseph P. Kennedy III is leaving his job as a prosecutor and laying the groundwork to run for the House seat that retiring Rep. Barney Frank (D-Mass.) has held for three decades.

Kennedy is forming an exploratory committee, a Democratic source confirmed, allowing him to start raising funds and organizing a campaign effort. He will wind down his work at the Middlesex District Attorney’s office over the next two weeks and make a final determination about a run sometime after that.

Kennedy won’t be alone in the race, but as the grandson of former presidential candidate and Sen. Robert Kennedy (D-N.Y.), he is a member of Massachusetts's legendary political family and so starts off with unmatchable advantages in name recognition and good will.

"The lack of common sense and fairness in Washington is a byproduct of the partisan gridlock that has turned obstruction into victory," Kennedy said Thursday in a statement. "My decision to look seriously at elected office is grounded in a deep commitment to public service and my experience – both my own and that of my family — in finding just, practical, and bipartisan solutions to difficult challenges."

The son of former Rep. Joe Kennedy II (D-Mass.), Kennedy attended Stanford University and Harvard Law School, and volunteered in the Peace Corps before becoming a prosecutor.

Frank, 71, delivered a surprise to Democrats in November when he announced he would not seek reelection in 2012, citing the unpleasant effects of redistricting.

The field to replace Frank hasn’t yet settled. But many Democrats who had considered running were believed to be awaiting Kennedy's decision.

"The fact that he's a conscientious individual drove him to put out the statement today, so he didn't hold up any other candidates or the media, or the people of the 4th district," said Kennedy spokesman Nick Clemons.

Republicans saw Frank’s retirement as their biggest opportunity in years to contest a House seat in Massachusetts, but those hopes will take a major blow if Democrats nominate Kennedy. Sean Bielat, the Republican who came within 11 points of unseating Frank in 2010, is expected to run again.

Joseph III's House campaign would mark the return of the Kennedy family to Massachusetts politics. Sen. Edward Kennedy (D-Mass.) died in 2009.

The head of the Massachusetts Democratic Party, John Walsh, called Kennedy a superb example of the abundance of Democratic talent in Massachusetts, but was sure not to take sides in what could still be a contested primary.

"Joe joins a list of top-notch Democrats who are weighing a run in this district," Walsh said in a statement. "Because of the quality of our candidates, we are confident the Democratic candidate will be the better choice to match the values and needs of the voters of the 4th District."

- This post was updatd at 3:01 p.m.