San Francisco’s Municipal Railway is rolling out the world’s oldest operating cable car this weekend — a relic that was brought back to life with a lot of work and a lot of pride.

Car No. 19 is a San Francisco survivor if there ever was one. It first went into service in 1883 and last carried paying passengers 77 years ago on the long-defunct Sacramento and Clay streets line. Since then, it has been stored, out of service, too valuable to be scrapped and too old to work.

Or so everybody said. That all changed more than a year ago, when Brent Jones was made superintendent of Muni’s cable car division. He liked the old car, and when maintenance workers proposed fixing it up and running it again, he agreed. “Everybody else said we couldn’t do it,’’ said Arne Hansen, shop superintendent at the carbarn at Washington and Mason streets.

“We have a lot of pride in our work here,’’ he said. So the crews worked on car 19, sometimes on city time and sometimes in their spare time.

There was a lot to do. The car had been kept in a corner of the carbarn gathering dust like an old piece of furniture in the back of someone’s basement. A few years ago it was taken to the cable car carpenter shop near Dogpatch for repairs. There was talk about running No. 19 again, but the car flunked operating tests — it is longer and heavier than the California Street cars, Muni’s biggest.

But a few months ago, Jones gave it the green light, and car 19 got new paint, new and better brakes, some modifications so it could make sharper curves than it encountered in its Sacramento Street days, and a new attitude. “You know people come from all over the world to see these cable cars,’’ said Danny Hicks, a painter who works on restoring cable cars when they get old. “We don’t want to give them a lot of junk. We want them to see something we are proud of.’’

So one late summer night, after the regular cable car lines had shut down and the city was mostly asleep, old No. 19 rumbled out of the carbarn for a test. They ran it it down through the Financial District, Hansen and other cable car staff aboard and watching carefully. A tow truck was ready in case something went wrong. “After 77 years, five months and 11 days, it ran fine,’’ Hansen said.

There was another test about a week ago with a carful of cable car technicians. I went along, too. That was fitting, in a way, because a Chronicle reporter was one of only two passengers on the last run of the Sacramento Street cable line in February 1942.

The Sacramento Street cable car ran from Sacramento and Fillmore streets to the Ferry Building, via Sacramento and Clay streets. It started in 1873, the world’s first cable line. “It passed from this life and this world quietly, without bravado,’’ reporter Robert O’Brien wrote. William Thomas, the cable car superintendent at the time, wrote its obituary. “Feb 15, 1942. At 1:30 A.M. ... both Sacramento cables were clamped and thown clear of the winding machinery and left dead on the floor. The end.’’

But it was not the end of No. 19, which began life running on Market Street in 1883. Cable cars, which had been invented in San Francisco 10 years earlier, were all the rage in public transit in 1883. Cable cars were as modern as tomorrow: They replaced horsecars in Chicago, Denver and even New York City.

But by the 20th century, only hilly San Francisco clung to cable cars. Car 19, which survived the 1906 fire and earthquake, is now 136 years old, the oldest operating cable car. The rest of the 10 Sacramento Street cars have all been scrapped. The Market Street Railway Co., which ran the car, is history, too.

If cable cars have a soul, this one still has it. It showed its stuff on a test run last week, taking the curves with ease and a loud squeal. It rumbled and clanked up and down hills, down Washington Street from the carbarn, down Powell Street and up Jackson Street — around the horn, in cable car parlance — then out Jackson to Hyde Street, and over to California. It ran the California line from one end to another, then out Hyde, down the steepest hill on the system to North Point Street, and back again.

Tom Leal, at the grip, and conductor Antonio Marquardt tried out the brakes on a hill. “This car will stop on a dime and give 9 cents change,’’ said David Kerrigan, who worked on the car’s brake system.

The car passed the test with flying colors. “We have a lot of pride in the cable car system,” Hansen said. “We all do.’’

Car 19 will run Sunday from 11 a.m. to 5 p.m. on the California Street line as part of Muni’s Heritage Week, a celebration of old-time buses and railcars.

The cable cars will be shut down for repairs to the power machinery for 10 days starting Friday.

Carl Nolte’s column appears Sundays. Email: cnolte@sfchronicle.com Twitter: @carlnoltesf