WASHINGTON — In the wake of two mass shootings, the divisive politics of gun control appeared to be in flux on Thursday as President Trump explored whether to back expanded background checks on gun purchasers and Senator Mitch McConnell, the Republican majority leader, signaled that he would at least be open to considering the idea.

It is not clear that either the president or Mr. McConnell will embrace such legislation, which both of them have opposed in the past and which would have to overcome opposition from the National Rifle Association and other powerful conservative constituencies.

But their willingness to weigh its political appeal and feasibility — or to be seen doing so — suggested that Republicans are feeling pressure to take some substantive action after mass shootings over the weekend in El Paso and Dayton, Ohio, that killed 31 people. Mr. McConnell said that a measure expanding background checks to all gun purchasers would be “front and center” when the Senate comes back into session next month.

“There is a lot of support for that,” he said in an interview with a Kentucky radio host, adding that the discussion would also encompass so-called red flag legislation that would make it easier to seize firearms from people deemed dangerous. Such legislation had already been gathering support from Republicans.