Robert Hazard, 59, the Philadelphia-bred rock troubadour who wrote the pop anthem "Girls Just Want to Have Fun," died unexpectedly Tuesday night after surgery at Massachusetts General Hospital in Boston, his widow, Susan, confirmed today.

Mr. Hazard, who lived with his wife and two teenage sons in the Adirondacks and in Vero Beach, Fla., last month had canceled a planned fall tour without explanation.

Robert Hazard and the Heroes, born out of the late-1970s punk movement, were a fixture on the local bar scene through the mid-1980s.

One night in a motel in Delaware, Mr. Hazard sat in a bathtub and in 15 minutes wrote "Girls Just Want to Have Fun," a sprightly pop tune covered in 1983 by Cyndi Lauper. Labeled a feminist anthem, it shot to No. 1. Miley Cyrus' remake is included on her new album, Breakout.

In an autobiography from 2003, Mr. Hazard - born Robert Rimato - acknowledged that his father was an opera singer. "Obviously, I didn't follow in his footsteps, but did learn a bit about music appreciation," he wrote. "I started singing and writing songs about about age 10. I didn't really play guitar till much later. In my teens I would audition at coffee houses like the Second of Autumn and the Edge" in the Philadelphia area. "I never got a job, but learned about acoustic music by hanging out at these places listening to Eric Andersen, Chris Smither, Jimmy Webb, and other great song writers and poet guitar players."

From his first marriage, he had a daughter, Corrina. With Susan, whom he married in 1986, he had sons Rex and Remy. The couple own an antiques shop near their home in Old Forge, N.Y.

In his autobiography, Mr. Hazard recounted his big break in 1982:

"One night, we were playing a little joint called J.C. Dobbs on South Street. Kurt Loder was in town to review the opening of a world tour by another band called the Rolling Stones, who were playing at JFK Stadium that same night. After the Stones concert, Kurt stopped into Dobbs for a beer. I stayed up talking with him till 5 o'clock in the morning. The next month, there was a two-page spread in Rolling Stone magazine, pictures and all, raving about the band. Soon after that, we were signed to RCA Records."

The Hazard song "Escalator of Life" charted soon after.

In more recent years, he delved into country, forming a band The Hombres. He said his favorite shows were what he called "the stripped-down acoustic concerts I did with my buddy Michael Pilla. I thought these were the most rewarding and the most appreciated by my audience."

Memorial services were incomplete today, though Susan Hazard said something would be planned for next week in his hometown.