Theodore C. Sorensen, John F. Kennedy's close advisor and writer-in-residence in the Senate in the 1950s who became special counsel to the president and remained chief speechwriter during Kennedy's tragically brief presidency, has died. He was 82.

Sorensen, who had a long post- White House career as a Manhattan-based international lawyer, died Sunday at New York Presbyterian Hospital/Weill Cornell Medical Center from complications of a stroke, said his wife, Gillian.

Once referred to by Kennedy as his "intellectual blood bank," Sorensen began his nearly 11-year relationship with the future president in 1953 when Kennedy was the newly elected senator from Massachusetts.

Hired as Kennedy's No. 2 legislative assistant, the 24-year-old graduate of the University of Nebraska School of Law soon was enlisted to help Kennedy draft his speeches and magazine articles, and he played a key role in the research and writing of "Profiles in Courage," Kennedy's Pulitzer Prize-winning 1956 bestseller.

Sorensen also became a trusted advisor to Kennedy, traveling with him to all 50 states in the four years leading up to his 1960 election as president.

After Kennedy moved into the White House, Sorensen advised the president on issues such as civil rights, the decision to go to the moon and the 1962 Cuban missile crisis, which was sparked by the discovery of Soviet nuclear-missile installations under construction in Cuba.

During the crisis, Kennedy asked Sorensen to draft, with guidance from Atty. Gen. Robert F. Kennedy, the crucial letter to Soviet leader Nikita Khrushchev that averted a nuclear confrontation between the two superpowers.

Jacqueline Kennedy once inscribed a photograph to Sorensen: "To Ted, who walked with the President so much of the way and who helped him climb to greatness."

In his 2008 autobiography "Counselor: A Life at the Edge of History," Sorensen acknowledged that Kennedy "was my hero."

During his early years with Kennedy, Sorensen wrote, "I learned not only loyalty but deference, reticence, becoming almost anonymous, never asserting, assuming, or bragging, for fear of antagonizing not only him, but also his father or his brother Robert, both of whom were fiercely protective of Jack's image and career."

His years with Kennedy "were unquestionably the cornerstone of my professional life; and the cornerstone of our relationship was mutual trust.

"JFK brought me into his inner circle, confiding in me secrets that — had I discussed them with others — might have done serious harm to his political career, his public image, or perhaps his marriage."

President Obama said in a statement Sunday: "I know his legacy will live on in the words he wrote, the causes he advanced and the hearts of anyone who is inspired by the promise of a new frontier."

Historian Robert Dallek, who wrote the 2003 Kennedy biography "An Unfinished Life," told the Associated Press in 2008 that Sorensen "served Kennedy brilliantly. And he was as close as any administration figure could get to Kennedy."

Over the years, Sorensen was often asked about his role in "Profiles In Courage," which chronicled acts of political courage in the Senate throughout history.

In the book's preface, Kennedy thanked Georgetown University professor Jules Davids and many others for their help but noted that the "greatest debt is owed to my research associate, Theodore C. Sorensen, for his invaluable assistance in the assembly and preparation of the material upon which this book is based."

The success of "Profiles in Courage" significantly increased Kennedy's national profile and stature as a politician. But it also spurred speculation that the book had been ghostwritten, in particular by Sorensen.

Responding to those charges, Sorensen stated in an affidavit at the time that the book's author was Kennedy, "who originally conceived its theme, selected its characters, determined its contents, and wrote and rewrote each of its chapters."

In his autobiography, Sorensen wrote that "JFK worked particularly hard and long on the first and last chapters, setting the tone and philosophy of the book. I did a first draft of most chapters, which he revised both with a pen and through dictation."