The pastor of McLean Bible Church apologized for hurting some members of his congregation by praying for President Trump during an unscheduled visit.

Trump visited the northern Virginia church on Sunday on his way back to the White House during a golf outing. His appearance at the church came the same day that evangelist Franklin Graham called for a special day of prayer for Trump.

Pastor David Platt said Trump’s visit was unexpected and he didn’t have time to think through his actions.

“My aim was in no way to endorse the president, his policies, or his party, but to obey God’s command to pray for our president and other leaders to govern in the way this passage portrays,” Platt said in a statement to members on the church's website.

“I know that some within our church, for a variety of valid reasons, are hurt that I made this decision,” the pastor said. “This weighs heavy on my heart. I love every member of this church, and I only want to lead us with God’s Word in a way that transcends political party and position, heals the hurts of racial division and injustice, and honors every man and woman made in the image of God.”

President Trump listens to Pastor David Platt as he prays for Trump at McLean Bible Church, in Vienna, Va., Sunday June 2, 2019. (Jacquelyn Martin/AP)

White House spokesman Judd Deere said Sunday that Trump had visited the church to pray for the victims of the mass shooting in Virginia Beach. The shooting, however, was not specifically mentioned in the pastor’s comments while Trump stood on stage.

Platt said after his sermon he was called backstage and told Trump would be arriving in a few minutes and wanted the congregation to pray for him.

“I’m guessing that all of us will face other decisions this week where we don’t have time to deliberate on what to do,” he said. “I’m praying now for grace and wisdom for all of us to do exactly what we talked about in the Word today: aim for God’s glory, align with God’s purpose, and yield to God’s sovereignty.”