President Obama on Thursday made a joke at the expense of Sen. Ted CruzRafael (Ted) Edward Cruz32 male senators back Senate women's calls to change harassment rules Senate confirms Trump’s pick to lead NASA DOJ denies reports judicial nominee once called illegal immigrants 'maggots' MORE (R-Texas) at a state dinner for Canadian Prime Minister Justin Trudeau. 

During his toast, Obama needled Cruz over widely debunked questions surrounding his eligibility to run for president.

The president said Americans and Canadians are both committed to the principle that “you can make it if you try,” no matter the circumstances of one’s birth.

“And we see this in our current presidential campaign,” Obama said. “After all, where else could a boy born in Calgary grow up to run for president of the United States?” 

The president made his crack at Cruz just minutes before a CNN Republican primary debate was set to begin.

Cruz’s chief rival in the race, businessman Donald TrumpDonald John TrumpHouse Republicans push Mulvaney, Trump to rescind Gateway funds Pruitt spent K flying aides to Australia to prep for later-canceled visit: report Rosenstein told Trump he is not a target of Mueller probe: report MORE, has repeatedly questioned whether the Texas Republican is a natural-born citizen — a constitutional requirement to be president. He was born in Canada to a Cuban father and American mother.

Most legal experts say Cruz’s Canadian birthplace isn’t an impediment to occupying the Oval Office. A New York judge this week threw out a lawsuit challenging his eligibility for to be president.

Obama is no stranger to the questions surrounding Cruz. Since he launched his first campaign, some of Obama’s critics have alleged he was born in Kenya and is not eligible to be president. Obama is a natural-born citizen; he was born in Hawaii to an American mother and Kenyan-born father.