The Senate voted 62 to 36 in favor of building the pipeline. Nine Democrats joined 53 Republicans in passing the bill. The passage sends the measure back to the House, which passed a largely similar bill this month. House leaders are deciding whether to pass the Senate bill as is or to hold a conference merging the House and Senate versions into a new bill to be voted on by each chamber.

Either way, the bill is expected to reach the president’s desk as soon as next week. It is unlikely, however, that either the Senate or House can muster the two-thirds majority of votes necessary to override a veto.

Mr. Obama, who currently retains authority to approve or deny the permitting of the pipeline because it crosses an international border, is expected to veto the bill because it would remove his executive authority to make the final decision. Senate Republicans said that if he vetoed the Keystone bill, they would add it on to another measure this year, like must-pass spending legislation or a broader energy bill.

But pressure is mounting on the president from both sides to make a final decision on Keystone construction, which has been pending since he took office.

Mr. Obama has repeatedly said that he is waiting for all reviews and processes to be completed before he makes a final decision. In 2013, he said that his verdict on the pipeline would be based on whether its construction would worsen climate change. But an 11-volume State Department environmental review of the proposed pipeline, released last year, concluded that its construction would not significantly increase the rate of planet-warming pollution into the atmosphere.