Charles B. Elder Sr., a former prisoner of war who spent 50 years trying to obtain the Purple Heart he earned during the Korean War, died Tuesday of respiratory failure at Gilchrist Hospice Care in Towson.

The longtime Hydes resident was 90.

Mr. Elder was 22 years old when he walked into the Towson Armory in 1949 and enlisted in the Army and was inducted into the service at Fort Meade.

After he completed basic training at Camp Pickett, Va., Mr. Elder was granted a 30-day leave and then reported to Fort Ord near Monterey, Calif.,for deployment to Korea.

“He had to go through basic training twice because his records were lost,” said John Donohue, a longtime friend who is a member of Ensign Kelly American Legion Post 174 in Timonium, as was Mr. Elder.

“In late 1950, I returned to San Francisco for shipment tp Japan,” Mr. Elder wrote in an account of his life. “We arrived in Japan in the town of Sasebo. We went by boat to Pusan in Southern Korea, where we were then transported by train to the front lines in April.”

He fought in what became known as the Battle of Heartbreak Ridge, north of the 38th parallel, which began on Sept. 13 and ended on Oct. 15, 1951.

During this battle, Mr. Elder, whose unit was encircled by North Korean soldiers, was taken prisoner. He had been wounded in the hip by artillery fire.

“I was wounded the day I was captured. I walked for a while until I was unable to walk any further. I was put on an ox cart as we zig-zagged back and forth across Korea to the prison camp,” Mr. Elder wrote. “We marched for 25-30 days before reaching the prison camp.”

During the journey, Mr. Elder was operated on by North Koreans in a roadside hut.

“They were using kitchen utensils and holding down my arms and legs with no anesthetic,” he wrote. “There were eight or ten in the ox cart during the march. I was the only one to survive the march to the prison camp,” where he was handed over to the Chinese.

Mr. Elder’s wound grew fetid and filled with maggots, he wrote.

He and his fellow soldiers were imprisoned under brutal conditions at a camp on the Yalu River on the border between North Korea and China.

To pass the time, Mr. Elder attended propaganda classes and endured interrogations and forced labor. Because communication with the outside world was limited and heavily censored, Mr. Elder’s family had no idea if he was dead or alive.

“Able soldiers were sent on wood detail, which involved carrying wood for the Chinese to keep warm. It was a cold winter, 40 to 50 degrees below zero,” he recalled in his memoir. “Clothing was cotton padded and huts with thatched roofs were heated by fires.”

After an escape attempt failed, Mr. Elder was placed in solitary.

The armistice was signed on July 27, 1953, Mr. Elder’s birthday. He was repatriated through Freedom Village on the 38th parallel and was eventually mustered out at Fort Meade.

“His parents had no idea he was coming home until he arrived at the family farm in Hydes,” said Mr. Donohue, a former Maryland National Guard lieutenant.

After leaving the Army, he worked on the family farm and studied at the Baltimore Engineering Institute.

He worked at Westinghouse Electric Corp. from 1955 to 1957 and then was a payroll accountant at AAI Corp. in Hunt Valley from 1957 until retiring in 1991.

When he asked about the Purple Heart, which he was entitled to receive shortly after leaving the Army, he was told the military had run out of medals.

For years thereafter, he was frustrated in his attempts to get the decoration, until 2014, when Mr. Donohue intervened on his behalf. “There had been a fire years ago in St. Louis that had destroyed many military records,” Mr. Donohue said. “That’s when I got my friend, Rear Adm. Dale E. Horan, to help.”

Admiral Horan was able to cut through the red tape and secure help in the Defense Department, which approved awarding the Purple Heart to Mr. Elder.

“In six months, he was able to achieve what I had not been able to in [60] years,” Mr. Elder told The Baltimore Sun in 2015, when Admiral Horan presented the decoration before a packed hall next door to the Jacksonville Senior Center in Phoenix, Baltimore County.

“POWs don’t like to say a whole lot,” Mr. Donohue said, “but in recent years, he opened up a little bit. He’s definitely a hero, but really didn’t want to talk about it.”

The son of farmers Francis Wyatt Elder and Jean Bailey Elder, Charles Bailey Elder was born and raised on Elder Farm on Hydes Road, where his family grew apples and peaches and raised poultry.

He was a 1945 graduate of Towson High School and attended McCoy College at the Johns Hopkins University from 1947 to 1948, when he returned to work on the family farm.

He was married in 1964 to Elizabeth “Betty” Williams, and the couple settled on the farm.

Mr. Elder was a member of the Veterans of Foreign Wars, Disabled American Veterans and Ex-POW Korean War Association.

He was also a member of the Johns Hopkins Club and the Jacksonville Senior Center, where his expertise kept model trains humming on the organization’s annual Christmas garden display.

In 1982, he was presented the Distinguished Service Award by the Little People of America on behalf of his work with the organization.

He was a longtime communicant of Trinity Episcopal Church in Glen Arm, where he served as senior warden, vestryman, and Boy Scout leader.

“I have been asking myself: ‘What is the happiest day of my life?’ ” Mr. Elder said in the 2015 Sun article on the Purple Heart ceremony.

“The day I married Betty 51 years ago and this day are even.”

A military funeral service will be held at 2 p.m. today in the parish hall of Trinity Episcopal Church, 12400 Manor Road, Glen Arm.

In addition to his wife, Mr. Elder is survived by his daughter, Frances W. Elder of Richmond, Va.; a brother, John S. Elder of Pennsylvania; a sister, Frances W. Baldwin of Catonsville; and two granddaughters. His son, Charles Bailey Elder Jr., died in 2012.