A crowd of several thousand greeted the president from the lawn of Canada's Parliament Building, with many waiting hours in a light snowfall for the chance to see his arrival. Obama and Harper offered the crowd a quick wave before walking inside for their meetings.
Acknowledging his support in Canada, Obama closed his news conference with Harper by saying: "I want to also, by the way, thank some of the Canadians who came over the border to campaign for me during the election."
"It was much appreciated," he said, drawing a round of laughter.
The meetings between the two officials were largely a chance for them to get to know each other. The only formal agreement announced covered cooperation on the development of environmental technology.
Obama also met with opposition party leader Michael Ignatieff before departing for Washington.
Four of the prior seven presidents chose Canada for their first visits outside the country, and many Canadians felt snubbed when President George W. Bush picked Mexico for his first foreign visit.
Obama's choice of Canada for his first trip beyond U.S. borders was celebrated as symbolically important in the country.
Though Canada's conservative government is ideologically closer to the Bush administration, and Harper maintained a close relationship with the former president, the prime minister praised Obama as a president who "epitomizes" the two countries' "shared value" of "equal opportunity."