A Coast Guard rescue swimmer whose disappearance led to a massive search in Hawaii pleaded guilty to desertion Tuesday, saying he left work one day, decided never to return and spent the next three months camping in the mountains of Oahu.

Petty Officer 1st Class Russell Matthews pleaded guilty to desertion and wrongful use of marijuana during a special court-martial in Honolulu on Tuesday before a Coast Guard judge. In exchange for his guilty plea, the Coast Guard dismissed charges of being absent without leave and causing the Coast Guard to conduct a search when there was no need.

"Your honor, I left work and I didn't have any intention of going back," he testified, describing how he went to pick up his children from school on Oct. 25 and then got into argument with his wife. He then drove to Kaena Point, a remote part of Oahu, and walked on the beach for several hours. Afterward, he camped in the mountains behind his kids' school, he said, where he stayed until he showed up at his wife's home in mid-January.

"That's a long time to be camping," said Coast Guard Cmdr. Kevin Bruen, the judge presiding over the court-martial. "How did you sustain yourself?"

"I had $20 in my pocket," Matthews said softly, seated at the defense table, flanked by his appointed Navy lawyers and wearing his service dress blues. "I did some... stuff I try not to remember."

Meanwhile, the Coast Guard launched a massive search. Members of the Coast Guard who participated in the search that scoured more than 10,000 square miles testified about the motivation to find one of their own, the speculation he may have tried to kill himself and then the mixed emotions that came when he turned up alive.

Pilots flew 64 hours searching over the waters off Kaena Point, taking Coast Guard members away from their normal duties and taxing aircraft. "He's part of our unit...we are family," said Cmdr. Prince Neal. Rescuers mourned his loss, only to find out he was alive. They felt happiness for his children, but also confusion, Neal recalled.

Lt. j.g. Curtis Gookin recalled searching for four days through rough ocean conditions, holding out hope they could recover his body and bring some solace to his family. When he surfaced months later, "I was really disgusted by his actions," he said.

Robert Coster, a civilian search-and-rescue coordinator, testified that the estimated cost of the search for the Coast Guard was more than $1 million.

The scenario Coster thought of during the search was that a well-trained rescue swimmer went into the ocean to commit suicide, changed his mind and was fighting the ocean to survive.

"This was an individual who was well-trained by the Coast Guard," Coster said. "He understood what we were doing for him."

Matthews didn't discuss more about his time in the wilderness, only saying he simply went back to where he lived and realized his wife and children had moved. The memories of what happened next are sketchy, he said, recalling that paramedics were called because he had a cut on his head and he ended up in police custody.

He admitted smoking marijuana in September and smoking several times during his desertion. "I smoked it in a joint, your honor," he testified. "Probably a few times, your honor."

Matthews' mother testified via telephone from the mainland that she was told he drowned, but she didn't believe it. "He would never do that to his children," Carol Matthews said. "I told them at the time I believed my son was AWOL." She said she told the Coast Guard he was likely in Puerto Rico or in the caves of Pupukea, on the north shore of Oahu.

He's expected to be sentenced Tuesday. The judge noted he'd already been held for 119 days.

Hawaii News Now previously reported that Matthews lost four colleagues in a 2008 helicopter crash. The following year, his first wife was critically hurt when she was hit head-on by a car while riding her bike. She died a couple of years later, according to public records.

Coast Guard attorneys prosecuting the case said his two sons are in the custody of his first wife's sister on the mainland.