ZIONSVILLE, Pa. — Ending a monthslong mystery that his opponent used to attack him, Sen. Pat Toomey said he voted Tuesday for Donald J. Trump.

The Republican incumbent, trying to fend off a challenge from Democrat Katie McGinty, had repeatedly refused to tell voters if his party's nominee would get his vote. But after refusing to endorse Trump for months, Toomey said Tuesday night, one hour before polls closed, that he had voted for the Republican nominee.

"In the end it was a tough call for me as I'm sure it was for many Pennsylvanians," Toomey said as he left his polling place near Allentown around 7 p.m.

Toomey said he had serious questions about Trump's judgment, but the importance of conservative issues was the defining reason.

"I really only came to this decision in the past couple of days," Toomey told reporters gathered outside his polling place. "This was a tough call for me. There are serious questions about his temperament and judgment... I had to weigh that against the possibility of what could be accomplished if he were president."

Toomey voted around 6:45 p.m. at a polling place in Zionsville — at an hour that meant most of the people deciding whether to re-elect him had already voted, without knowing whom he supported for the presidency.

"I really only came to this decision in the last couple days," Toomey said.

Toomey, who for his entire campaign did not endorse or reject Trump, repeatedly said he was waiting to be persuaded by Trump. Even after some of Trump's biggest missteps, though, when other Republicans were denouncing the candidate, Toomey would not take a stance.

He said he would never vote for Hillary Clinton.

He had said he would probably tell voters before Election Day, but at the last Senate debate also said he did not believe constituents cared who he voted for.

"In the end I decided we've just gotta change the course we're on, so I voted for Donald Trump," he said.

He didn't respond to criticism from Democrats that he waited too late to tell voters, saying McGinty has criticized him "every single day about something."

At a watch party for Toomey Tuesday night, supporter Linda Larson, 56, of Carlisle, said she was nervous about the Senate race but glad that Toomey ultimately voted with his party.

"It disappoints me when the Republican Party doesn't support each other," she said.