Mr Trudeau toasted the two nations as "siblings" at a state dinner.
Mr Obama raised his glass at the White House to the "great alliance" and joked about Mr Trudeau's previous jobs.
"If things get out of hand, remember the prime minister used to work as a bouncer," said Mr Obama.
In a joking reference to Canadian-born presidential candidate Ted Cruz, Mr Obama said: "Where else could a boy born in Calgary run for president of the United States?"
A lavish state dinner was held for Mr Trudeau and his wife Sophie Gregoire-Trudeau, featuring poutine, Nanaimo bars and white chocolate snowballs.
During Mr Trudeau's toast, he referred to the 25,000 refugees from Syria who have arrived in Canada in the past four months, saying that "diversity can be a source of strength".
More than half of US governors oppose allowing refugees to settle in their states.
A new life in Canada for Syrian refugees
Can Trudeau be what Obama couldn't?
What Canadians make of the US election
After a private meeting at the White House, Mr Trudeau said he had learned a lot from "my friend Barack", who he described as "a man of both tremendous heart and tremendous intellect".
Earlier, Mr Obama said the two leaders share "a common outlook" and that Mr Trudeau had brought "new energy and dynamism not only to Canada but to the relationship between our nations".
He added that the US and Canada were "blessed to be neighbours".
The leaders have pledged co-operation on liberalising investment and trade, promoting clean energy and preventing foreign fighters from travelling to the Middle East.
Mr Trudeau came bearing gifts for the First Family: a pair of Canadian-made dog boots called "Muttlucks" for the pet dogs, a beaded cape for Mrs Obama, an aboriginal statue for Mr Obama, and scarves for the president's daughters.
Ahead of the meeting, a joint statement on environmental cooperation announced that the US and Canada would cut methane emissions by 40-45% below 2012 levels, by 2025.
They also agreed to set "world class" standards on commercial activities in the Arctic, including oil and gas exploration.
US-Canada relations had previously suffered because of energy issues, when Mr Obama's administration opposed the Keystone XL pipeline, which was meant to transport oil from Canadian tar sands in Alberta to the US Gulf coast.
President Obama, 54, sees in the young leader a man who shares his progressive politics, as well as his early rhetoric of hope and change, the BBC's Barbara Plett-Usher reports from Washington.
Mr Trudeau's optimistic election platform has led many to draw comparisons with the beginning of Mr Obama's presidency and some American liberals to draw envious comparisons with the US's political scene.
As Donald Trump solidified his position as front-runner for the Republican presidential nomination earlier this month, there was even a spike in internet searches about how to move to Canada.
In Washington, Mr Trudeau chose his words carefully after being asked by reporters for his views on US-Canada relations under a Donald Trump or Ted Cruz presidency.
He said he looked forward to working with whomever US voters elected to the White House.

England seamer Jake Ball, Luke Fletcher and James Pattinson all took three wickets as Durham were out for 162.
Stuart Poynter provided the only real resistance, scoring 65 off 59 balls before he was bowled by Fletcher.
Notts lost 17 overs of their reply to bad light, but seamer Chris Rushworth took two early wickets to help reduce the away side to 96-4 at stumps.
Durham, playing their first game since being relegated from Division One and docked 48 points over financial issues, could have been in far worse position had it not been for Poynter's second first-class half-century.
The Ireland international struck 12 fours in his innings to put pressure on the Notts attack, with his 52-run last-wicket partnership alongside Rushworth giving his side hope of getting back in contention on day two.
US President Barack Obama and Canada's new Prime Minister Justin Trudeau have lavished praise on each other during the first official visit by a Canadian leader in nearly 20 years.
[NEXT_CONCEPT]
Nottinghamshire's bowlers dominated on the first day at the Riverside before Durham fought back with the ball.