President Bill Clinton and artist Nelson Shanks, standing, at the 2006 unveiling of an official portrait of Clinton at the National Portrait Gallery. (Michel duCille/The Washington Post)

Nelson Shanks, who painted portraits of prominent leaders and who stirred a controversy this year when he revealed that he included a subtle reference to the Monica Lewinsky scandal in his painting of President Bill Clinton at the National Portrait Gallery, died Aug. 28 at his home in Andalusia, Pa. He was 77.

He had prostate cancer, said Bill Wedo, a spokesman for Studio Incamminati, an art school in Philadelphia that was co-founded by Mr. Shanks.

Mr. Shanks painted well-known subjects such as Princess Diana, Pope John Paul II, a group portrait of the first four women to serve on the U.S. Supreme Court and presidents Ronald Reagan and Clinton. He was called “the most talented contemporary traditional portraitist” by D. Dodge Thompson, chief of exhibitions at the National Gallery of Art in Washington.

The artist’s portrait of Clinton standing beside a White House fireplace was unveiled in 2006, five years after it was begun. It was paid for with private funds.

“I think the painting really feels like Bill Clinton,” Mr. Shanks told The Washington Post at the time. “It has — I would not call it swagger . . . What? An informality? A looseness, a relaxed nature.”

Artist Nelson Shanks with his painting, “The Four Justices,” portraying the first four female justices of the U.S. Supreme Court, at the National Portrait Gallery in 2013. (Manuel Balce Ceneta/AP)

Nine years later, Mr. Shanks told the Philadelphia Daily News that a shadow in the painting near the former president was a reference to the infamous blue dress supposedly worn by Lewinsky, a White House intern, during an intimate encounter with Clinton. The stained dress was turned over to the staff of independent counsel Kenneth Starr during an investigation of the affair.

The artist placed a mannequin wearing a blue dress in his studio to add authenticity and to symbolize what he called a lingering shadow over Clinton’s presidency.

“He and his administration did some very good things, of course,” Mr. Shanks told the Daily News, “but I could never get this Monica thing completely out of mind, and it is subtly incorporated in the painting.”

Clinton also was depicted without his wedding ring, which Mr. Shanks called an oversight.

The painting was on display at the National Portrait Gallery, but it has been in storage since 2009, in what the gallery calls a standard rotation of artworks.

John Nelson Shanks was born Dec. 23, 1937, in Rochester, N.Y., and grew up mostly in Wilmington, Del. He studied painting at the Kansas City Art Institute and later in New York and Italy.

He became known for his realistic, meticulous portraits of notable leaders, business magnates and performers, including opera stars Luciano Pavarotti and Denyce Graves.

Mr. Shanks taught at several art schools before launching the Studio Incamminati in Philadelphia in 2002 to teach figure-painting and other realist techniques.

In an interview with the Philadelphia Inquirer in 2001, as he was working on Clinton’s portrait, he spoke about his philosophy of portraying people on canvas.

“I try to push portraits as far as I can beyond the academic, traditional, straightforward boardroom style,” he said. “I try to bring the art out.”

Mr. Shanks’s paintings typically sold for $200,000 or more. After painting a portrait of former British prime minister Margaret Thatcher, he turned to Princess Diana, completing a formal portrait of her in 1994. He considered the princess one of his “dear friends,” he told the Associated Press after she died in 1997.

Mr. Shanks’s first marriage ended in divorce. Survivors include his wife, Leona Shanks; four children; and four grandchildren.

In 2002, Mr. Shanks interrupted work on his Clinton painting to honor a request from the Vatican to paint a portrait of Pope John Paul II.

“The painting needs to be perfection,” he told the Philadelphia Inquirer of the artwork that would hang in a Vatican museum alongside works by Renaissance painters Michelangelo and Raphael.

“Is it the most important thing I’ll ever paint?” Mr. Shanks said. “Yes, most definitely.”