(Reuters) - Joseph Kennedy III, grandson of the late Senator Robert F. Kennedy, won the Democratic primary for Massachusetts' 4th Congressional District on Thursday, CNN reported.

The primary triumph marks the first election victory by a member of his generation of Kennedys, and virtually ensures he will win the general election in November in a solidly Democratic district that last elected a Republican in 1944.

No other member of the Kennedy family holds public office at the moment.

Kennedy, 31, defeated two lesser-known Democrats to win his party's nomination for the seat being vacated next year by veteran Democratic Congressman Barney Frank, who is retiring after three decades in the U.S. House of Representatives.

In November, Kennedy will face off against Republican candidate Sean Bielat, who beat Elizabeth Childs, a state mental health commissioner under former Governor Mitt Romney, in their party's primary.

Kennedy is heir to one of America's most storied political dynasties as the son of former Democratic Congressman Joseph P. Kennedy II, who founded the nonprofit Citizens Energy Corp in 1979 and represented Massachusetts' 8th Congressional District for 12 years.

His grandfather, Robert F. Kennedy, served as U.S. attorney general for his brother, President John F. Kennedy, and later as a U.S. senator from New York. Robert F. Kennedy was assassinated in 1968 just after winning the California primary race for president. President John F. Kennedy was assassinated in 1963.

Joseph Kennedy III previously served as a Massachusetts prosecutor, worked in the Peace Corps and worked on the final election campaign of his great uncle, Senator Edward Kennedy of Massachusetts, who died in 2009.

(Reporting by Chris Francescani in New York and Steve Gorman in Los Angeles; Editing by Lisa Shumaker)