The last of thousands of F-4 Phantom jets that have been a workhorse for the U.S. military over five decades are being put to pasture to serve as ground targets for strikes by newer aircraft.

But first some well-earned honors.

The Air Force will hold a "final flight" retirement ceremony Wednesday at Holloman Air Force Base in New Mexico, where the last F-4s are still flying for the U.S. military. The ceremony will celebrate the airplane's rich military history as the jet was a mainstay during the Vietnam War and used for decades for reconnaissance missions and anti-missile electronic jamming.

McDonnell Douglas — now part of the Boeing Co. — built more than 5,000 F-4s for the Air Force, Navy and Marine Corps. It first flew in the late 1950s, and production ended in 1985.

An F-4 Phantom from Wittmund Air Base, Germany, flies beside a KC-135R Stratotanker from the 100th Air Refueling Wing, RAF Mildenhall, England, during a training mission Feb. 5, 2013, over Germany. Both the F-4 and the KC-135 platforms have been used by air forces worldwide since before the Vietnam War.

Photo Credit: Master Sgt. Latisha Cole/Air Force

The last F-4s still flying for the U.S. military took on a different role, serving as aerial targets and test aircraft during Air Force training over the New Mexico desert. The planes are either flown by pilots or remotely as drones by controllers on the ground. They've been used as targets for missiles and also used to test new radars and other missions. But with the retirement this week, the planes will no longer fly and instead be used as ground targets.

That the plane stayed in service so long is a testament to a range of roles that the F-4 could handle thanks to its large size, powerful engines and a two-member crew, said Jeff Duford, a National Museum of the Air Force research curator.

While other aircraft could handle some of the same missions, "there were none that were as flexible as the F-4," Duford said.

"It was not the best of anything but it could do everything," said Craig Schorzman, a retired Air Force colonel who lives in Tucson, Arizona, where he trained to fly the F-4 in the 1960s while at Davis Monthan Air Force Base before deploying to Germany and then Southeast Asia.

"It wasn't the best air-to-air but we could do it. It could do close-air support (of ground troops). It could do bombing. It could do any role, including nukes — we could do it."

The aircraft "was hardy and very sturdy," Schorzman said, recalling times when his plane made it back to base despite being shot up. "It saved my tail a few times."

Schorzman said the fighter-bomber could use a precision guidance system to guide bombs to their targets. "We could go into a mouth of a cave."

The Navy originally got production F-4s to intercept enemy bombers threatening U.S. aircraft carriers, and initial models relied on air-to-air missiles. They were later fitted with guns during the Vietnam War to combat enemy fighters.

As a dogfighter, the F-4 wasn't great but could counter North Vietnam's more nimble MiG fighters by using its more powerful engines to climb to get into a good position or get out of a bad one, Schorzman said.

While other aircraft such as the F-15 supplanted the F-4 in the fighter-bomb role, it still flew on for many years as camera-toting reconnaissance jets and in electronic-warfare versions that blinded enemy anti-aircraft missiles' guidance systems.

"I think it really speaks to the usefulness of the platform," Duford said.

The remaining 13 QF-4s at Holloman are flown by a detachment of a squadron at Tyndall Air Force Base in Florida, and dozens of the target planes have been shot down either over White Sands Missile Range near Holloman or over the Gulf of Mexico.

The Tyndall squadron has already converted to flying F-16s as aerial targets, and the Holloman detachment is getting its first F-16 target version this week.