The following correction was printed in the Guardian's Corrections and clarifications column, Tuesday 1 September 2009

In the obituary below of Edward Kennedy we mentioned the death of his aviator brother Joe, "killed in action in France in 1944". Joe Kennedy's Liberator aircraft set out on a mission to France, but it blew up over Suffolk.

Edward Kennedy – the last survivor of the three Kennedy brothers who left an indelible political mark on their age – has died at the age of 77. Though the manifest flaws in his character cost him the American presidency in 1980, time and circumstance ensured that his eventual contribution to his compatriots' welfare could well prove to be his enduring legacy, eclipsing the memory of his turbulent private life and the scandal surrounding the death of Mary Jo Kopechne at Chappaquiddick in 1969.

His death marks the end of five decades in which the brothers had symbolised the progressive impulses of the Democratic party. He was first elected to Congress by Massachusetts voters in 1962, and eventually achieved the second-longest Senate term in US history. This enabled him to create an unrivalled legislative record, dealing with such concerns as healthcare, education and training, safety at work and a wide range of other social concerns. His remarkable capacity for work and his pragmatism in securing a consensus among his colleagues won him wide respect from both parties.

In May 2008 Kennedy collapsed at his home and was found to have a malignant brain tumour. He underwent immediate surgery, followed by radiation treatment and chemotherapy. To the astonishment of delegates, he made an appearance at the Democratic convention in Denver, Colorado, in August to express his strong support for Barack Obama as the party's presidential nominee, having endorsed his candidacy the previous January at a crucial stage in the campaign.

With the scar from his surgery clearly evident, and with many delegates in tears, Kennedy mounted the podium to produce an echo of the remarkable speech he had made at the 1980 New York convention, when his campaign against President Jimmy Carter for the Democratic nomination collapsed. In a strong voice, he told the audience in Denver that "this November, the torch will be passed to a new generation of Americans. The work begins anew, the hope rises again and the dream lives on." It was a tacit acknowledgment that his own part in the process was drawing to a close.

Edward Moore Kennedy, widely known as Ted, was the youngest of Joseph and Rose Kennedy's nine children, a factor that was important in the development of his complex and contradictory personality. At his birth, his nearest sibling, Jean, was four and his eldest brother, Joseph, was nearly 17. The boy turned out to be a good-natured child who, with the increasing absence of his father and brothers, was treated with the utmost indulgence by his mother and sisters. He commented in later life that those early years had passed "having a whole army of mothers around me".

When he was six, his father's appointment as ambassador to Britain brought a traumatic change to this secure and sheltered domestic scene. After the move to London, the child never seemed to be allowed to establish himself anywhere. By the end of the second world war, when he was 13, he had attended 10 different schools. He privately acknowledged that the emotional effect of this disruption was to leave him with virtually no recollection of his life between the ages of seven and 18. His aviator brother Joe was killed in action in France in 1944, and Edward became increasingly conscious of the heightened expectations his parents had of their remaining sons.

The family's history since it fled the Irish famine in 1848 had been one of relentless material and political advance. Grandfather Patrick Kennedy, a Boston saloon keeper, had been elected to the Massachusetts state legislature at the early age of 27. From that vantage point, he shrewdly harnessed his new influence in the struggle against the dominant Yankee establishment. His mastery of wheeling and dealing soon gave him political control of the impoverished Irish area of east Boston. With the power to deliver the voters of this fiefdom to Boston's Democratic party machine, Patrick's advance was spectacular.

He became a state senator and then moved into a variety of appointed offices in the city at what was then the enormous salary of $5,000 a year. From there he advanced steadily up the party ladder and was soon accepted as one of Boston's most powerful figures. Within a decade, using bribery, dead men's votes, intimidation and any other weapon that came to hand, the Irish factions gained control of Boston. They have never lost it.

In spite of this political success, Patrick realised that a social gulf remained. He decided to send his son Joseph – Edward's father – to the Boston Latin school, attended by most of the children of the city's elite families. Young Joseph was not academically successful there, but his talent as a baseball player led to a number of useful friendships. When his attempt to replicate this process at Harvard University failed, his father used his political clout by securing him a place in the college basketball team.

The pattern of the Kennedy clan had thus been established – to win any struggle it undertook without bothering too much about the means. This pattern was heightened when Joseph Kennedy, in a series of extremely risky deals, bludgeoned his way into the tightly controlled Boston banking community and then, as a figure of growing consequence, married Rose Fitzgerald, the mayor of Boston's daughter.

His bride was as steeped in local politics as her new husband, having often acted as her father's hostess and grown accustomed to the pressures and accommodations his position entailed. This was the atmosphere in which their rapidly growing family was raised. Both parents stressed to their children the importance of winning. Merely to try their best was not enough.

It was an affluent life, though the source of Joseph's fortune has never been wholly clear. While some of it was acquired through bootlegging during prohibition in the 1930s, other elements came more legitimately from the film industry and complex stock market manipulations. It meant the family was never concerned about its material wellbeing. It had three large homes and the children benefited from trust funds established by their father that would reach $10m apiece in his lifetime.

This wealth also enabled Joseph to buy as much political influence from the Franklin Delano Roosevelt administration as he wanted (including the London ambassadorship). The effect on his youngest son of growing up in this amoral climate soon became apparent. Like his brothers, Edward had inherited his father's sporting prowess. By the time he began at Harvard in 1950, he was more than six feet tall, weighed 15 stone and had become a notable player of American football.

He was keen to join the university team but was hampered by a poor record in his studies. Unlike other US universities, Harvard made sporting advancement dependent on a sound academic performance. Faced with a Spanish examination he was sure he would fail, Kennedy paid a more adept friend to take it for him. To the chagrin of his family, the plot was discovered and he was expelled, though the incident was covered up for more than a decade.

With his exemption from military service now void, he was conscripted into the army from 1951 to 1953. The family appeared to regard his brief service career as a form of punishment and made no effort to ease his lot. He never got beyond the rank of private and in his biographical listings, that period was dismissed in four words.

There was, however, clearly considerable negotiation going on behind the scenes, because he was allowed to return to Harvard after his military discharge. Possibly as a reaction to military discipline, his increasingly erratic temperament began to emerge. To the horror of his team-mates in a football match against a side from New York, he was sent off after three times starting fights on the field. He did not like being bested.

Although he got a BA in government at Harvard (1956), he failed to qualify for its law school and enrolled instead at that of the University of Virginia. He again jeopardised his career there with a series of motoring offences, including jumping a red light on a suburban street at 90mph. However, he graduated as a bachelor of law in 1959 and was immediately admitted to the Massachusetts bar.

Just before graduation he had met and married Joan Bennett, but even with a wife to support, he was hardly in need of a paying job. Kennedy had started to benefit from his father's trust fund and, having acted as manager of his older brother John's 1958 Senate re-election campaign, was now recruited for the next stage of the family's grand plan, John's bid for the White House. For the most part he was sent to work in the western states, most of them hopeless prospects with a long history of voting Republican.

It fell to his brother Robert to control the central campaign, in which John scraped into the White House in 1960 as the country's first Roman Catholic president by a margin of 113,000 votes out of 69m. His victory was subsequently attributed to large-scale ballot rigging by the Chicago mayor Richard Daley's Irish-run administration. The episode starkly underlined an adage of Thomas "Tip" O'Neill, one of the Kennedy family's closest allies in Boston and later speaker of the House of Representatives. In the end, he declared, all politics was local. It was a lesson Edward Kennedy absorbed, and would underpin his entire political career.

With John as president (and Robert his attorney general), the Massachusetts Senate seat fell vacant, but Edward was still two years below the minimum legal age to take over. So it was held by a nominee until the Kennedys could reclaim it in the 1962 election. Edward won the remainder of John's term by an overwhelming majority, partly through crude hints that the family would now be able to shower the state with federal largesse.

A year later JFK was assassinated. Edward was in the Senate chamber when the news was brought to him. He gathered his papers silently and left the chamber to discover more. But the Washington telephone system had collapsed under the weight of calls, and he arrived at the family home in Hyannis still unclear about the precise circumstances of his brother's death. His father was by now frail and bedridden and it fell to Edward and his sister Eunice to break the news to him the following morning.

In the private turmoil that followed the murder, the senator's public life had to continue. He was obliged to fight once more for his newly won seat because its six-year term had expired. While criss-crossing the state to gather support, his private plane crashed. Kennedy was the only passenger who had not fastened his seat belt, and he sustained six spinal fractures and two broken ribs. He spent six months in hospital and never wholly shook off the effects of the injuries.

But the combination of Kennedy money and widespread sympathy for the family ensured an easy victory, and his political career hit its stride. There was, of course, considerable hostility between the remaining brothers and President Lyndon Johnson, and the vehicle for its expression became the Vietnam war. Edward joined with Robert – who had secured one of New York's Senate seats in the 1964 election – to focus the country's increasing disenchantment with the conflict.

As American troops became mired more deeply, Robert announced he would fight Johnson for the 1968 Democratic presidential nomination. Within days, the president withdrew from the contest and Robert looked certain to be the party's candidate. He had just won his sixth primary, in California, when he, too, was assassinated. It had a cataclysmic effect on Edward, now the only remaining brother.

At the funeral he gave a short, spontaneous address which many felt was the most moving speech of his life. "My brother need not be idealised or enlarged in death beyond what he was in life," he said. "He should be remembered simply as a good and decent man, who saw wrong and tried to right it, saw suffering and tried to heal it, saw war and tried to stop it."

Robert had left 10 children and a pregnant widow. His brother now had to assume responsibility for them as well as for his own growing family, particularly when it soon became evident that his sister-in-law, Ethel, could not cope. One of his staff wrote later that "kids in various states of undress ran amok, Ethel scurried about screaming orders at the top of her lungs. The kids had adopted nearly a dozen cats and dogs and these ran about with the same abandon as the children."

The strain began to show on Kennedy, notably in his increased consumption of alcohol. It surfaced publicly when he went on a Senate fact-finding trip to Alaska the following spring. His staff and the accompanying journalists noticed him taking constant drags from a hip flask on the flights and then searching out bars at each stop. On the homeward flight he repeatedly teetered down the aisle, spilling his drinks on other passengers.

He was also having difficulties with his marriage. Like his father and brother John, he had a voracious sexual appetite. Joe Kennedy, in addition to a long-lasting liaison with the film star Gloria Swanson, had had a large number of flings. John's inheritance of these propensities was notorious, and his youngest brother's became equally so.

The Washington gossip circuit was awash with increasingly lurid accounts of Edward's frequently bizarre sexual behaviour. Though some of the tales undoubtedly grew in the telling, others were authenticated by reliable witnesses. One of the most notorious was when Kennedy was observed in sexual intercourse with a woman lobbyist in the booth of a Washington restaurant. On another occasion he was photographed in the act on a boat. He made little effort to hide from his wife this procession of young women.

A younger Ted Kennedy as he appeared on American television's Meet the Press. Photograph: NBCUPHOTOBANK/Rex Features

In parallel with this misconduct, however, Kennedy was establishing a well-deserved reputation on Capitol Hill as a diligent and effective legislator. In the face of President Richard Nixon's determined efforts to cut back on welfare and other federal programmes for the needy, Kennedy emerged as the champion of the poor and black people.

His reputation among his peers reached the point where they elected him the Senate's youngest ever majority whip, a position only one step below that of Democratic leader in the chamber. There was a widespread assumption – not least in the White House – that he would be the Democrats' candidate when Nixon sought re-election in 1972. Then came the incident at Chappaquiddick that dominated the rest of his life.

The bald circumstances have been rehearsed endlessly since they occurred on the night of 18-19 July 1969 – the eve of the first manned landing on the moon. Kennedy had been competing in a regatta off Martha's Vineyard, one of a cluster of Massachusetts islands. At the end of the race he went to Chappaquiddick Island, just across a narrow sound to the east of Martha's Vineyard, for a party arranged by his cousin in an isolated cottage. The guests were six young women who had worked on Robert Kennedy's campaign and six men, including Kennedy. The party was supposedly to thank the women for their election work.

At about midnight Kennedy left the cottage, accompanied by 28-year-old Mary Jo Kopechne, ostensibly to take her to the Edgartown ferry so she could return to her hotel. Kennedy missed the main road and, driving at speed down a narrow dirt track, ran off a narrow bridge. His car overturned and rolled into about 10 feet of water.

That is the extent of the undisputed facts of the case. Kennedy claimed that having extricated himself from the car, he made repeated dives in an attempt to rescue Kopechne. He then walked the mile and a half back to the cottage and sought help from his cousin and a lawyer who was joint host. The three returned to the scene to make further unsuccessful efforts to retrieve Kopechne.

The accounts of the next few hours changed repeatedly, and few of them withstood the intense media investigations of the following years. The one incontestable fact was that Kennedy failed to report the accident for more than 10 hours and, even by his own account, had behaved appallingly. The public uproar intensified when he made a self-pitying television statement and reached its peak when the inquest was held in private. The judge ruled that Kennedy "was probably guilty of criminal conduct" but made no move to indict him.

This obvious manipulation of the local judiciary by the state's most powerful family was probably more damaging in the long term than the tragedy itself. As with the Watergate conspiracy a few years later, it was the cover-up that caused the outrage, allied to Kennedy's apparent readiness to put his political career ahead of a young woman's life.

But Kennedy himself seemed curiously unable to grasp the effect of the incident, not least that it had destroyed any prospect of him becoming president. Though his record of bringing funds into his home state secured him re-election in 1970, the immediate fallout from the scandal was to cost him his position as Senate whip. He was also forced to rule himself out of the 1972 presidential election, which Nixon won with a landslide.

In 1976, press investigations of what had happened at Chappaquiddick kept the issue in the public mind. That, along with Nixon's resignation in 1974 after the Watergate scandal, made Democrats highly sensitive about their own political skeletons. Kennedy again felt obliged to rule himself out of the White House contest.

But in 1979, with Carter in deep trouble at home and abroad, Kennedy announced he would seek the 1980 Democratic nomination. Though the opinion polls were initially heavily in his favour, his campaign was a disaster from the outset. In an extraordinary nationwide television interview, he was completely incoherent when asked why he wanted to be president.

The media was filled with accounts of his history of sexual misbehaviour, his now notorious use of alcohol and drugs, and the Chappaquiddick accident. Even the deeply unpopular Carter began to win one primary election after another and, though Kennedy continued the battle through to the party convention, he was finally forced to cede the nomination to Carter.

Perhaps with the realisation that he had no hope of ever reaching the White House, he again made a superb speech to the convention, calling on delegates to fight for the ideals that had informed the party from the days of Franklin Roosevelt. "For me, a few hours ago, this campaign came to an end. For all those whose cares have been our concern, the work goes on, the cause endures, the hope still lives, and the dream shall never die."

He then returned to the politics of which he was an expert practitioner – patient crafting of legislation in Senate committees, the endless negotiation and dealing required to secure its passage, and unremitting attention to the detailed concerns of the voters at home.

Through all his political and private vicissitudes, the Massachusetts electorate continued to return Kennedy to Washington because he delivered the goods. A federal contract here, a new highway there, a restored railway in New Bedford, a grant to clean up a polluted bay; after more than three decades as their representative, his patronage amounted to hundreds of millions of dollars.

The pundits thought his time had finally come during the 1994 campaign. By then he had been involved in a rape case in which his nephew was eventually acquitted, and he had felt obliged to make a humiliating public statement about his abysmal personal life. "I am painfully aware of the disappointment of friends and many others who rely on me to fight the good fight. I recognise my own shortcomings, the faults in the conduct of my private life."

It followed a familiar pattern that Kennedy had evolved down the years – contrite public statement after a particularly outrageous incident. It was attacked by one commentator as "a speech most other drinkers make with a borrowed quarter", but Kennedy still racked up his usual two-to-one victory in a year that saw the Republicans finally gain full control of Congress.

He had now become the fourth most senior member in the Senate. In this position he was one of 23 senators who opposed the congressional resolution authorising President George W Bush's invasion of Iraq in 2003. It enabled him to become the leading voice in the opposition to the war.

Shortly after Bush staged his infamous "mission accomplished" declaration, Kennedy brusquely assured Americans: "There was no imminent threat. This was made up in Texas. [Bush] announced to the Republican leadership that war was going to take place and was going to be good politically. This whole thing was a fraud." He accused White House officials of "distortion, misrepresentation and selection of intelligence to justify the war. My belief is that money is being shuffled around to political leaders in all parts of the world, bribing them to send in troops."

When Kennedy returned to the Senate last November, after Obama's victory, he announced his intention "to lay the groundwork for early action by Congress on health reform when President Obama takes office in January". In spite of the gravity of his illness – diagnosed as glioblastoma, the deadliest form of brain cancer – he had insisted on continuing his political life. He had been active in supporting his niece Caroline's short-lived campaign to be the New York governor's selection to fill Hillary Clinton's vacant Senate seat and, as one of Obama's earliest and most prominent supporters, had turned out in the bitterly cold Washington winter for January's inauguration.

During the luncheon after Obama's swearing-in, Kennedy began shaking uncontrollably due to a combination of fatigue and the extreme cold. He was discharged from hospital the following day but these attacks – usually shielded from public view – are a common feature of brain cancer and had become regular. It was plain that he was in decline.

Kennedy's first marriage ended in divorce in 1982. It had produced a daughter, Kara, and two sons, Edward Jr and Patrick, who is a congressman for Rhode Island. In 1992, he married Victoria Reggie, a family friend. She and his children survive him.