Nigeria's government has condemned reports that its citizens, and those of other African countries, have been stopped from leaving war-torn Ukraine.
Isaac, a Nigerian man trying to get into Poland, said border staff told him they were "not tending to Africans".
"We've been chased back, we've been hit with police armed with sticks," he told the BBC.
South African foreign office official Clayson Monyela also said students had been "badly treated" at the border.
There have also been numerous reports of Ukrainian security officials preventing Africans from catching buses and trains going to the border.
Osemen, from Nigeria, told the BBC he had tried to get on a train in Lviv to take him to the Polish border but was told only Ukrainians would be allowed on board.
Nigeria's President Muhammadu Buhari said there were about 4,000 Nigerians in Ukraine, mostly students.
He said one group had repeatedly been refused entry to Poland so they travelled back into Ukraine to head for Hungary instead.
"All who flee a conflict situation have the same right to safe passage under the UN Convention, and the colour of their passport or their skin should make no difference," Mr Buhari said in a tweet.
More than 500,000 Ukrainians have managed to flee the Russian invasion so far.
'Hotel only for Ukrainians'
University student Ruqqaya, from Nigeria, was studying medicine in Kharkiv in the east of the country when the city was attacked. She walked for 11 hours overnight before she arrived at the Medyka crossing with Poland.
"When I came here there were black people sleeping on the street," she told the BBC.
She says she was told by armed guards to wait as Ukrainians had to be let through first. She watched busloads of people, whom she described as white, being allowed through the border while only a handful of Africans were selected from the queue. After waiting for many hours, she was finally allowed to cross and made her way to Warsaw to fly back to Nigeria.
Asya, a medical student from Somalia studying in Kyiv, had a similar account. When she finally reached Poland, she said she was told "accommodation at the hotel was only for Ukrainians".
She is now safe in Warsaw, where she's staying in a hotel. In stark contrast to her experience at the border, she's found people in the city to be incredibly kind and welcoming.
All of the African and Asian students she's in touch with have been offered free accommodation. She said the reception had been overwhelming.
The Polish border force told the BBC that everyone fleeing conflict in Ukraine was being welcomed into Poland regardless of nationality. The BBC has tried to contact the Ukrainian border force but has yet to receive a response.
Nigeria's Foreign Minister Geofrey Onyeama said he had spoken with his Ukrainian counterpart Dmytro Kuleba and had been assured that Ukrainian border guards had been given an order to allow all foreigners leaving Ukraine to pass without restrictions.
Nigeria's ministry of foreign affairs has now advised its citizens leaving Ukraine to head for Hungary or Romania, rather than trying to enter Poland.
The Nigerian ambassador to Romania has told the BBC that so far about 200 Nigerians - mostly students - have arrived in the capital Bucharest from Ukraine. Safiya Nuhu said many more were still arriving.