Larry Hagman, the American actor who played the nefarious oilman J.R. Ewing in popular TV series Dallas, has died at age 81.

His family said in a statement that he died Friday afternoon in a Dallas hospital of complications of cancer.

"Larry was back in his beloved hometown of Dallas, re-enacting the iconic role he loved the most. Larry's family and closest friends had joined him in Dallas for the Thanksgiving holiday," the family said.

The actor was surrounded by friends and family before he passed peacefully, "just as he'd wished for," the statement said.

Hagman had undergone a liver transplant in 2005 and treatment for throat cancer as recently as 2011.

A stage actor early in his career, Hagman made his name primarily in TV, first in the soaps and later as astronaut Maj. Anthony Nelson in I Dream of Jeannie.

Dallas made him an international star, both in the original series, which ran 1978 to 1991, and the more recent show, which began its run in June 2012.

jr-ewing-larrry-hagman-300-ap-03635218

This 1981 file photo shows Larry Hagman in character as J.R. Ewing in the TV series Dallas. (CBS/Associated Press)

Linda Gray, his on-screen wife and later ex-wife in the original series and the sequel, was among those with Hagman in his final moments, said her publicist, Jeffrey Lane.

"He brought joy to everyone he knew. He was creative, generous, funny, loving and talented, and I will miss him enormously. He was an original and lived life to the fullest," the actress said.

With its twisted family dynamics, soapy plots and cliffhanger endings, Dallas was a phenomenon. As J.R. Ewing, Hagman was the man the world loved to hate. His scheming and greed kept the Ewing family divided and TV viewers mesmerized.

Hagman said he'd modelled J.R. after a Texan he'd known who had four sons "and when he died the four sons were all jockeying over who was going to take over the empire."

In 1980, the "Who Shot J.R.?" episode drew 83 million people, a record at the time for a single TV episode. It had 400 million viewers around the world. In an interview with the BBC, Hagman recalled travelling to Romania and being recognized.

"A guy came up to me with tears in his eyes and said 'Thank you, J.R. for saving Romania.' I said 'What?' He said 'You saved this country. We were allowed to have three television shows a day and two were political speeches and the other was Dallas to show how corrupt the morals of the United States was," Hagman recalled. "Big mistake. People saw what was happening in America and they wanted that."

2 Emmys for Dallas portrayal

Hagman's other major foray into American living rooms couldn't have been more different. He played genial astronaut Maj. Anthony Nelson on I Dream of Jeannie, the 1960s sitcom also starring Barbara Eden. 

As Maj. Nelson, Hagman spent most of the series trying to hide the fact that he'd found a genie in a bottle. Eden, glamorous in her harem outfit, calls him "Master" and complicates his life by using her magic in an effort to fix problems.

Born in Fort Worth, Texas, Hagman was the son of actress Mary Martin and a local attorney, Benjamin Hagman. His parents divorced when he was five and he split his time between his grandparents in Texas and his mother in New York.

After falling in love with acting in high school, he attended Bard College in New York state and followed his mother into acting.

He appeared in the New York City Center production of  The Taming the Shrew, did a year in regional theatre and five years in London as part of the cast of his mother's South Pacific.

larry-hagman-eden-jeannie-300-ap-03635230

This 1967 file photo shows Barbara Eden, left, and Larry Hagman in a scene from the TV show I Dream of Jeannie. (NBC/Associated Press)

He served in the U.S. air force during the Korean War, where he produced and directed several series for members of the service.

After completing his service in the air force, he appeared in Broadway and off-Broadway productions of plays such as Once Around the Block, Comes A Day and The Nervous Set.

Hagman began his television career in 1961 with a number of guest appearances on such shows as The Alcoa Hour before getting a role for two years on the popular daytime series The Edge of Night in 1956.

"They didn't have Teleprompters in that time and it was live and if you goofed up, you goofed up. There was no coming back," Hagman said of his time on the soap. "I did a couple of years of that and it really paid off. You got confidence after a while."

His other TV credits included The Good Life, Here We Go Again and Applause, a TV version of the Broadway musical in which he played opposite Lauren Bacall.

Then Dallas made him a household name. Hagman was nominated twice for an Emmy Award for his role as J.R. Ewing and became the highest-paid actor in television after it became clear to producers his character was driving the show. A couple of Dallas reunion movies followed.

Later projects included hosting Lone Star, an eight-part documentary series about the history of Texas, and appearing in Oliver Stone's movie, Nixon. He also had roles in recent TV series such as Desperate Housewives and Nip/Tuck.

Hagman told a Dallas fanzine he had never seen Desperate Housewives before he was offered the part of Frank Kaminsky.

"He's a terrible man: ultra, ultra rich and very profane and just awful. I mean he's much more awful than J.R.," he said. "J.R. had some subtleties to him - this guy's straight-out bad."

Heavy drinking leads to cirrhosis

In 1995, Hagman needed a liver transplant, after years of heavy drinking led to cirrhosis of the liver. He was successful in getting a donor and spent seven weeks in hospital, but the procedure was controversial among people who felt he had caused his own illness with too much alcohol.

After that experience, Hagman became a prominent spokesman for organ donation and adopted a healthier lifestyle. He also created the Larry Hagman's Stop Smoking for Life video for the American Cancer Society.

In his autobiography, Hello Darlin': Tall (And Absolutely True) Tales About My Life, he also admitted to trying LSD and finding it a "profound experience in my life that.. changed my pattern of life and my way of thinking."

He also spoke of marijuana and mescaline use in the book.

Later in life, Hagman became an advocate for a green lifestyle and showed off the solar energy he harnessed at his home.

In 1954 Hagman married Swedish-born Maj Axelsson, who he met in the U.K,  They had two children, Heidi Kristina and Preston and lived in Ojai, Calif. In 2008 Maj Hagman was diagnosed with Alzheimer's disease.