Here’s a guy who figured out how to be both the luckiest and unluckiest man on the face of the earth at the same time.

One crazy afternoon in June of last year, maintenance man Degli Martinez learned he had won a $65 million Lotto jackpot – the largest single prize in the 30-year history of the state Lotto game.

He then promptly lost the ticket.

That began a yearlong odyssey of hand-wringing and heartburn before Lottery officials were finally able to hand Martinez his check yesterday.

SEE THE PHOTOS: Lotto Winner Collects!

“It was a lot of pain waiting,” said the 55-year-old Paraguayan immigrant at a lower Manhattan press conference.

Martinez’s wild tale began on June 29, 2007, when he bought a handful of tickets at a minimart in Sunnyside.

He returned the following day and had store clerk Supriyo Bhattacharjee scan the ticket bar codes to check for winners.

Bhattacharjee found a $2 winner and a couple of losers and then his eyes widened with surprise.

More NEWS From the New York Post

A-Rod’s Wife Breaks Her Silence

Brinkley Settles Ugly Divorce Trial

Jesse Jackson’s a ‘Nut’ Job

“He was the jackpot winner!” the clerk recalled yesterday.

Bhattacharjee printed a receipt, handed it to Martinez and urged him to go to the Lottery office in lower Manhattan to claim his winnings as soon as possible. Martinez headed home but accidentally tossed the ticket in the trash. He still had the receipt, and Lottery officials confirmed the winning ticket had been sold at the store.

But Martinez had to cool his heels for a year because, by law, whoever turned in the actual ticket would be entitled to collect, and officials had to make sure no one did so by the 365-day deadline.

Martinez, a maintenance man at a posh Park Avenue apartment building, and wife Maria waited with bated breath.

“I was nervous. You never know how these things will turn out,” Maria said.

Finally the deadline passed and Martinez was declared the winner.

He opted for a lump-sum payment that – after taxes – amounts to $21,176,066.

He said he wasn’t sure exactly what he was going to do with the money – except pay his daughter’s college tuition. And he isn’t ready to quit his job.

“For now I’m going back to work. At least until I can find someone to replace me. It’s hard to leave a job you love,” he said.

Lottery spokeswoman Carolyn Hapeman said that about $70 million in prize money goes unclaimed annually.

Also collecting yesterday was 59-year-old home health aide Linda Holley of The Bronx, who won a $19 million Lotto jackpot in May.

“I thank the Lord for allowing me to win this,” she said.

Additional reporting by Eric Shilling

austin.fenner@nypost.com