James Garner, a master of light comedy who shot to fame in the 1950s as the charming and dry-witted gambler on the TV western “Maverick” and later won an Emmy as the unconventional Los Angeles private eye on “The Rockford Files,” has died. He was 86.

Garner died Saturday at home, his publicist Jennifer Allen said. Garner, who lived in Los Angeles, underwent quintuple bypass heart surgery in 1988 and suffered a stroke in 2008. He had been in poor health for some time but the cause of his death was not immediately known.

Once described by Washington Post TV critic Tom Shales as having “embodied the crusty, sardonic and self-effacing strain of American masculinity” in his iconic roles as Maverick and Rockford, the Oklahoma-born Garner amassed more than 80 movie and TV-movie credits during his career of more than 50 years.

An off-screen Hollywood maverick who successfully battled two studios in court, Garner easily moved between small screen and big screen in roles ranging from light comedy to drama.

“I have long thought that Jim Garner was one of the best actors around,” filmmaker Robert Altman, who directed him in the 1980 comedy “Health,” told Esquire magazine in 1979.

“He is often overlooked because he makes it look so easy, and that is not easy to do,” Altman said. “I don’t know anyone in the business with his charm and charisma who can act so well.”

Garner was nominated for an Academy Award for his role as a widowed small-town pharmacist opposite Sally Field’s much younger single mother in the 1985 romantic comedy “Murphy’s Romance.”

His other films included “The Children’s Hour,” “The Great Escape,” “The Americanization of Emily,” “The Thrill of It All,” “Move Over, Darling,” “Grand Prix,” “Support Your Local Sheriff,” “Marlowe,” “Victor/Victoria,” “Space Cowboys” and “The Notebook.”

But it was television that made Garner a household name, and once he returned to series TV in the early 1970s after a decade starring in films, he remained a welcome presence on the small screen.

A RELUCTANT HERO

That included stints as a celebrity pitchman for entities such as the Beef Industry Council, Mazda, Chevy Tahoe and, most famously, Polaroid cameras.

The humorous series of Polaroid spots Garner made with actress Mariette Hartley in the late 1970s and early ’80s only burnished Garner’s status as a TV icon.

Garner’s seemingly effortless flair for delivering humorous dialogue – and delivering straight dialogue humorously – made him one of television’s biggest stars.

“Television is a close-up, intimate medium: The audience falls in love with Jim as a friend,” Brandon Stoddard, then a senior vice president of ABC, told Esquire magazine in 1979.

Signed as a contract player at Warner Bros. in the mid-1950s, Garner – a handsome, 6-foot-3, black-haired Korean War veteran – launched his Hollywood career with guest shots on TV shows such as “Cheyenne” and small parts in a few films.

He was on location in Japan playing the supporting role of Marlon Brando’s Marine Corps captain buddy in the 1957 romantic drama “Sayonara” when he learned that Warner television wanted to test him for a new series called “Maverick.”

The hourlong western-adventure series made its debut on ABC in September 1957. Arriving at a time when a slew of westerns such as “Gunsmoke” and “Have Gun Will Travel” dominated the airwaves, “Maverick” stood out.

Although the show began as a relatively straight western, the writers quickly began injecting humor into the scripts, a development Garner handled with aplomb.

As Bret Maverick, the dapper roving gambler, Garner was anything but a traditional western hero: He was, as Garner later put it, a reluctant hero.

“Maverick” began with Garner as the sole star. But when first-season filming fell behind, Jack Kelly was brought in as Maverick’s brother, Bart. Two companies then began filming Garner and Kelly in separate episodes and sometimes together.

The series’ tongue-in-cheek formula worked: Within two months, the upstart “Maverick” had passed the rival Ed Sullivan and Steve Allen shows in the Sunday-night ratings.

“Maverick” brought Garner an Emmy nomination for best actor in 1959, the same year the show won an Emmy for best western series. “Maverick” ran until 1962, but Garner left the show in 1960.

He had been unhappy with Warner Bros. over his relatively low salary and the studio’s control over his career. And when the studio suspended him without pay during a writers strike, he successfully sued and got out of his contract.

Garner turned his attention to movies and soon formed his own company, Cherokee Productions.

ROCKFORD AS ANTIHERO

Clint Eastwood, who played a heavy in a “Maverick” episode before landing his own TV series, “Rawhide,” in 1959, later said it “didn’t take long for producers to realize that Jim would make a great movie star.”

“Nowadays, television actors become movie stars all the time, but back then, in the late ’50s, it wasn’t easy,” Eastwood said in the 2001 tribute “Clint Eastwood on James Garner” that aired on Turner Classic Movies.

“There was a sort of prejudice at that time for guys who were on television, the theory being that if you saw him every week on television for free, why pay to see him in a movie?” said Eastwood, who directed and co-starred with Garner in the 2000 film “Space Cowboys.” “But Jim proved that wasn’t the case, which opened the door for people like Steve McQueen and myself.”

Garner starred in 21 films from 1961 through 1971, the year he returned to television as the star of “Nichols,” an NBC western set in 1914 Arizona. The show lasted a year.

But then came “The Rockford Files,” which ran on NBC from 1974 to 1980 and starred Garner as private eye Jim Rockford.

The action-drama was devoid of private-eye cliches. Instead of a secretary, Rockford had an answering machine, and instead of an office, he worked out of the weather-beaten house trailer that he lived in at the beach. And though Rockford could be daring when confronting the bad guys, he was not above admitting to them that he was “scared to death.”

“If you look at it, he’s not a hell of a lot different from Maverick,” Garner told Daily Variety in 2005. “They’re antiheroes, both of them, and, for an actor, that’s probably the most fun kind of leading man to play.”

The series earned Garner an Emmy in 1977.

But the show abruptly ended in 1980. Under doctors’ orders to take time off because of a bleeding ulcer, Garner could not continue working and NBC announced a replacement series.

In 1983, Garner filed a lawsuit against Universal alleging that the studio had used so-called creative accounting to cheat him out of his 37.5 percent share of the profits for “The Rockford Files” from syndication and foreign sales.

In his 2011 memoir “The Garner Files,” Garner said the case was settled “on the courthouse steps” in 1989. He had sued Universal for $22.5 million – $7.5 million in compensatory damages and $15 million in punitive damages. Although he had promised not to reveal what Universal paid him, he wrote, his wife had to keep telling him to wipe the grin off his face.

After leaving “Rockford,” Garner devoted most of his professional life over the next three decades to television. Some of his best roles were in TV movies and miniseries.

He received Emmy nominations for “Heartsounds,” “Promise” (a special for which he shared an Emmy for producing), “My Name Is Bill W.,” “Decoration Day,” “Barbarians at the Gate” and “Breathing Lessons.”

He also returned to his role as Rockford in eight “Rockford Files” TV movies in the ’90s and co-starred that decade with Mel Gibson in the 1994 film “Maverick.”

In 2005, Garner received a life achievement award from the Screen Actors Guild.

DRIFTED INTO ACTING

The youngest of three sons, he was born James Scott Bumgarner on April 7, 1928, in Norman, Okla. His mother died when he was 4 and his father, who ran a country store, later remarried.

It was not a happy home for Garner and his brothers, Charles and Jack. Their stepmother, Garner later recalled, regularly beat them “with anything she could get hold of.”

Near the end of World War II, the 16-year-old Garner dropped out of high school and joined the merchant marine. A victim of chronic seasickness, he soon quit and moved to Los Angeles, where his father lived.

While briefly attending Hollywood High, Garner was recommended by his football coach for a $20-an-hour job modeling Jantzen swimsuits for magazine ads.

After working in oil fields in Oklahoma and Texas and holding various odd jobs, Garner was drafted into the Army in 1950 during the Korean War. He served in the infantry and was wounded twice.

After his discharge, he briefly attended the University of Oklahoma, and then returned to California and worked with his father as a carpet layer. At a loss for what to do with his life, he fell into acting.

Paul Gregory, a friend who years earlier had encouraged Garner to become an actor, by then was a producer and agent. He took Garner on as a client.

Gregory soon put Garner in the Broadway-bound play he was producing: “The Caine Mutiny Court-Martial,” directed by Charles Laughton and featuring a cast that included Henry Fonda, John Hodiak and Lloyd Nolan.

As one of six judges in the court-martial, Garner had a nonspeaking part. The play opened on Broadway in 1954 and ran for a year. A national tour followed, with Garner playing Lt. Stephen Maryk, a role originated by Hodiak. Within a year, Garner was at Warner Bros.

While making the 1966 film “Grand Prix,” Garner developed a fascination with auto racing and owned the American International Racing team in the late 1960s. He participated in both on-road and off-road racing and drove the pace car three times at the Indianapolis 500.