Larry Hagman, 81, whose character J.R. Ewing on the celebrated television show “Dallas” became one of the most enduring villains in American television history, died in that Texas city Friday, according to a statement from his family.

He died at Medical City Dallas Hospital, the family said in a statement first released to the Dallas Morning News. The cause of death was complications from Hagman’s recent battle with cancer, his family said.

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

“When he passed, he was surrounded by loved ones. It was a peaceful passing, just as he had wished for,” the statement said.

As oil magnate J.R. Ewing, the actor shocked, astounded and fascinated millions of viewers through more than 300 episodes, by placing before them the essence of scheming villainy, and seeming to devote a kind of slippery charm to testing the limits of duplicity and sharp practice.

He was at the center of a world of greed, dynastic intrigue and chilling ma­nipu­la­tion amid the romance of oil drilling, and cattle ranching, and the mystique of Texas and the West.

On screen, he wore a western hat, and a grin that seemed to show his delight in his conniving ways.

Nothing less than worldwide frenzy was created when he fell victim to gunfire in the last episode of the 1980 season. Few major issues seemed more compelling than the question of “Who Shot J.R.?”

The “Who shot J.R.?” story line in which Hagman’s character was nearly murdered provided huge ratings. An estimated 41 million viewers tuned in to find out and made the episode the second most-watched entertainment show of all time, trailing only the “MASH” finale in 1983 with 50 million viewers.

The original series ran on the CBS network from April 1978 to May 1991. New episodes began to air on the TNT network this year. There was no immediate comment from Warner Bros., producer of the show, or TNT on how the series would deal with the loss of Hagman.

The Texas-born son of Broadway actress Mary Martin, the actor spent a year at Bard College in New York, and had worked steadily in movies, television and the theater for many years. He made appearances in more than 60 theatrical movies and TV productions.

An Air Force veteran himself, one of his best-known roles was as an Air Force officer in the popular television series “I Dream of Jeannie.”

Hagman also starred in two short-lived sitcoms, “The Good Life” (NBC, 1971-72) and “Here We Go Again” (ABC, 1973). His film work included well-regarded performances in “The Group,” ‘’Harry and Tonto” and “Primary Colors.”

He drank heavily for years, and it was reported that a liver transplant in 1995 had saved his life.

He and his wife, whom he married in 1954, had two children and lived in California.