John Pinto was born in December 1924 to a family of Navajo shepherds

John Pinto, a Navajo code talker during World War II who went on to a long career as a Democratic state lawmaker in New Mexico, has died at age 94, his party announced.

Pinto was the longest-serving senator in the state, having been first elected in 1977 and remaining in office until his death on Friday, the New Mexico Senate Democrats said.

"This is an extraordinary loss to Senator Pinto's family, the state of New Mexico, the country and anyone who knew and loved him," state Senate majority leader Peter Wirth said in a statement.

Pinto was born in December 1924 to a family of Navajo shepherds and grew up in Arizona and New Mexico, the Senate statement said.

During World War II, he served in the Marine Corps as a code talker -- the native Americans recruited to relay battlefield communications in a spoken code based on their tribal language, which the Germans and Japanese never cracked.

Some 400 Navajo took part in the project, along with members of several other tribes. None of the original 29 code talkers who invented the language are still alive. The last, Chester Nez, died in 2014.

"The debt we owe for that service, and the service of all Code Talkers, can never be repaid," New Mexico Governor Michelle Lujan Grisham said in a statement.

Navajo Nation President Jonathan Nez hailed Pinto as a "great Dine warrior" who "dedicated his life to helping others."

Grisham ordered all state flags to fly at half-staff in Pinto's honor.