NEW YORK — A historic four-masted sailing ship that’s been a tourist attraction for 42 years left New York City’s seaport district for good Wednesday on a journey that will eventually return it to its birthplace in Hamburg, Germany.

The Peking, built of riveted steel in 1911 with the tallest mast reaching 170 feet, departed under cloudy skies from a pier at the South Street Seaport Museum. The 377-foot-long vessel was pulled by two barges to a Staten Island dry dock where it will be readied for its trans-Atlantic crossing atop a heavy-lift ship next spring.

Once in Hamburg, it will undergo a $25 million restoration and become part of a planned maritime museum.

“The Peking is an important witness of the maritime history of Hamburg,” said Joachim Kaiser, a board member of the Stiftung-Hamburg Martim. “We will bring her back to her old glory.”

The Peking was one of seven sister nitrate clippers that carried guano from South America that was used for making fertilizer and explosives.

Kaiser said the Peking made 34 trips around the treacherous Cape Horn of South America.

After it was retired in 1933, it served as a cargo ship, as a school ship for training merchant marine German officers and as an English floating maritime school. The Seaport Museum saved it from being scrapped in 1974.

The Peking’s departure comes as the museum is about to welcome back the Wavertree, a three-masted sailing ship that has undergone a 16-month, $13 million restoration. The museum is also home to three other historic ships.

“The best part of the story for me is that the Peking was headed to be scrapped when the museum purchased her, and we’ve kept her alive for 42 years,” said Captain Jonathan Boulware, the museum’s executive director. “In 2016, she could have gone to scrap, but instead she’s got a good home that is all funded.”

Boulware said maintaining two big sailing ships was financially challenging for the museum, which suffered setbacks from Superstorm Sandy, the Great Recession and 9/11.

He said the Peking never came to New York, but the Wavertree, a 325-foot-long wrought-iron vessel built in England in 1885, did.

“It’s the right ship for New York so we’re bringing back an appropriate ship in excellent condition rather than having two ships in pretty dodgy condition,” he said. “In the early 20th century, the Wavertree is the kind of ship you would have seen in South Street Seaport every day of the week.”

It returns Sept. 24.