If Chester Nez dared to use his Navajo language in school, punishment was swift and literally distasteful. He had to scrub his tongue with a toothbrush and wash out his mouth with bitter soap.

So he was intrigued when recruiters from the Marine Corps showed up in 1942 seeking young men who knew both English and Navajo.

That day, four months after Japanese bombs fell on Pearl Harbor, Mr. Nez helped form an elite, top-secret group that became known as the Navajo code talkers. Using the Navajo language, they developed an unbreakable military communications code, then risked their lives on battlefields across the Pacific to send and decipher messages critical to America and its allies in World War II.

He didn’t have to volunteer; barred from voting, Native Americans were barely considered citizens. But Mr. Nez’s heritage spoke louder than decades of rejection.

“I reminded myself that my Navajo people had always been warriors, protectors,” he wrote in a 2011 memoir. “In that there was honor. I would concentrate on being a warrior, on protecting my homeland.”

Mr. Nez, the last of the original 29 code talkers, died June 4 at his son’s home in Albuquerque, N.M. He was 93 and had kidney failure, said Judith Schiess Avila, who helped Mr. Nez write his memoir, “Code Talker.”

In 2001, he received the Congressional Gold Medal, the highest civilian honor awarded by Congress, from President George W. Bush during a ceremony at the U.S. Capitol.

One of five children, Chester Nez was born Jan. 23, 1921, in Two Wells, N.M., on the Navajo reservation. His mother died when he was about 3. When he was about 9, his struggling father packed him off to government boarding schools to learn English and other skills that might help him succeed among whites.

The Marines showed up at his high school in Tuba City, Ariz., in the spring of 1942. The recruiters did not say why they needed Navajos, but the promise of adventure appealed to a teenager whose future otherwise seemed to offer little more than growing corn and beans or tending sheep.

“The Navajo feeling is to go to the top of the hill and see what’s on the other side,” he told the Los Angeles Times in 2001.

After boot camp, Mr. Nez and the other 28 Navajos chosen for the project were sent to Camp Elliott in San Diego. It was there that they learned the daunting nature of their assignment.

The Japanese had already broken every code used by the Allies, so when Philip Johnston, a World War I veteran who had grown up on a Navajo reservation, proposed using the Navajo language as the basis for a new code, the top brass thought it was worth a try.

In many respects, Navajo was perfect for the task: It had no written form, used complicated syntax and had unusual tonal features that added another layer of difficulty.

For 13 weeks, Mr. Nez and his fellow recruits were confined to a room at the base where they were instructed to come up with words to represent the letters A to Z as well as a code for military terms.

“Everybody thought we’d never make it,” Mr. Nez recalled. “It seemed impossible because even among ourselves, we didn’t agree on all the right Navajo words.”

But the code finally emerged.

“Wol-la-chee,” the Navajo word for “ant,” represented A, “na-hash-chid”, the word for “badger,” was B, “moasi,” the word for “cat,” was C, and so on. Several commonly used letters were represented by two or three Navajo terms, making the code even more complex.

For key military words, they relied on easy-to-remember images. The Navajo word for eggs, “a-ye-shi,” for example, meant “bombs.” “Ni-ma-si,” or “potatoes,” signified “grenades.”

Once they agreed on the code, the Navajo Marines began to practice it, demonstrating speed and accuracy. Messages that had taken 30 minutes to code and decrypt using other systems were translated and deciphered in 20 seconds by the Navajo code talkers.

The first message Mr. Nez transmitted in combat was at Guadalcanal in November 1942: “Enemy machine gun nest on your right flank. Destroy.”

After Guadalcanal, Mr. Nez never stopped moving, encrypting, relaying and deciphering messages about strategy, casualties, supplies and enemy positions. He served near the front lines at the Battle of Bougainville in Papau New Guinea in November 1943, Guam in July 1944 and Peleliu and Angaur in September 1944. The code talkers were so crucial to the war effort that they were not permitted to take leave.

“We were almost always needed to transmit information, to ask for supplies and ammunition and to communicate strategies,” Mr. Nez wrote in his memoir. “And after each transmission, to avoid Japanese fire, we had to move.”

Ultimately, more than 400 Navajos served as code talkers. During the battle on Iwo Jima, they conveyed and decoded 800 messages without error in the first 48 hours of the operation. “Were it not for the Navajos, the Marines would never have taken Iwo Jima,” Maj. Howard Conner, the leading Marine signal officer at Iwo Jima, wrote in a memo.

Mr. Nez avoided serious injury but was once threatened at gunpoint — by a fellow G.I. who thought he was a Japanese soldier.

He remained in the Marines through the Korean War. Civilian life proved difficult at times. The code talkers were forbidden to talk about their activities for more than two decades, until their mission was declassified in 1968. Mr. Nez had nightmares about the carnage he witnessed.

For many of his fellow code talkers, the secrecy order made it hard to get a job because they couldn’t tell employers what they had done during the war.

“Chester was one of the lucky ones,” Avila said in an interview. “He got an interview at the VA hospital in Albuquerque and was hired to be a maintenance guy. He was a painter. Sometimes he painted lovely things,” including murals depicting Navajo culture. He retired in 1974.

His marriage to Ethel Pearl Catron ended in divorce. Four of their six children predeceased him. Survivors include two sons, Michael Nez of Albuquerque and Tyah Nez of Boise, Idaho; nine grandchildren; and 11 great-grandchildren.

“I worried every day that I might make an error that cost American lives,” Mr. Nez told CNN a few years ago. “But our code was the only code in modern warfare that was never broken. The Japanese tried, but they couldn’t decipher it. Not even another Navajo could decipher it if he wasn’t a code talker.”