(CNN) -- Canadian Prime Minister Justin Trudeau apologized Wednesday after a photo emerged of him wearing brownface during a school event in 2001.
"I shouldn't have done it. I should have known better, but I didn't," he told reporters on an airplane. "And I'm really sorry."
He said it was a racist photo but he didn't consider it racist at the time.
It was a photo taken when he was a teacher in 2001, attending an end-of-the-year gala with an "Arabian Nights" theme, he said.
The future prime minister attended the event with friends and colleagues and was dressed as a character from Aladdin, said Zita Astravas, speaking on behalf of Trudeau's party, the Liberal Party of Canada. He was wearing a turban. The existence of the photograph was first reported by Time, a CNN affiliate.
Trudeau said he also put on makeup for a high school talent show in which he sang.
Trudeau is running for reelection. He is in a virtual tie for the election with Conservative Andrew Scheer.
"I stand here before Canadians as I will throughout this campaign and talk about the work we have to do to make a better country together," Trudeau said. "And I am going to continue to stay focused on that and continue to work to fight intolerance and discrimination, even though obviously I made a mistake in the past."
The election is October 21. Scheer, speaking at an airport tarmac in Sherbrooke, Quebec, said: "Like all Canadians, I was extremely shocked and disappointed when I learned of Justin Trudeau's actions this evening. Wearing brownface is an act of open mockery and racism. It was just as racist in 2001 as it is in 2019. What Canadians saw this evening was someone with a complete lack of judgment and integrity and someone who's not fit to govern this county."
The leader of the Green Party, Elizabeth May, said she was "deeply shocked by the racism shown in the photograph."
"He must apologize for the harm done and commit to learning and appreciating the requirement to model social justice leadership at all levels of government," May tweeted. "In this matter he has failed." Trudeau, 47, was sworn in as prime minister in November 2015. Trudeau, son of Pierre Trudeau, is the first child of a Canadian prime minister to become prime minister himself.