Matthew Fox knew months ago that he wanted to propose to his girlfriend, Lonnie Nemiroff, at the Long Island Marathon Sunday.

He just wasn’t sure he’d be able to make it across the finish line to do it.

Nemiroff, 27, is an avid runner who has run several endurance races. Fox, 26, originally of Old Westbury, is not.

But after training for months, the couple finished the 13.1-mile half marathon together in a little over two hours. And with their friends and family looking on at the finish line, Fox dropped to one knee and popped the question.

She said yes.

Despite the wet weather, Nemiroff, originally from Roslyn Heights, said it was the “perfect proposal.”

advertisement | advertise on newsday

“I couldn’t have asked for anything better,” said Nemiroff, who’s finishing up a master’s degree in social work at New York University. “I love running, and it was perfect for me to be proposed to in exercise clothes.”

The couple, who now live together in the West Village, met while attending the Wheatley School in Old Westbury. Fox, a lawyer, said he “fell for her in the first grade.”

He started planning the proposal back in January. He began training in order to keep up with his soon-to-be fiancee, and also arranged for Nemiroff’s sister Perri, who ran the half marathon with the couple, to fly out from California.

“I wanted to surprise her doing something that she loves,” Fox said. “The marathon was the perfect opportunity. I love Lonnie, and I’m just excited for what’s to come.”