They are the first to be punished under a law which came into effect in the state of Zamfara earlier this week, forbidding the carrying of Muslim female passengers on motorbikes.
The new law is the latest element of Sharia, or Islamic law, to come into effect, after the state official adopted Sharia in January.
Each of the riders received 20 strokes of the lash.
Our correspondent in Gusau, Ibrahim Dossara, told the BBC's Focus on Africa that about 300 people gathered to see the punishment meted out.
One of the men cried as he was beaten.
Women escape beating
The passengers were not punished because they were married - but our correspondent says an unmarried woman caught riding a motorbike would be punished.
Our correspondent says 200 other motorbike riders have been arrested for the same offence, and are awaiting trial.
Until now, the motorbike taxis have been a popular form of transport for women in Gusau, the main city in Zamfara state.
The Zamfara authorities are also enforcing Islamic bans on prostitution, and on games of chance like ludo and cards.
'Misunderstood'
The state of Yobe recently became the seventh northern state to introduce or announce plans to implement Sharia since the country's return to civilian rule last year.
The governor of Yobe, Bukar Abba Ibrahim, signed a bill on Monday to enforce the code from 1 October.
Correspondents say the issue has polarised opinion in Nigeria, where it is opposed by the predominantly Christian south.
Muslims in northern Nigeria feel strongly that Sharia has been misunderstood by Christians, who have tended to concentrate on the fact that it introduces punishments such as amputation for theft and flogging for people caught drinking alcohol.
Four more states - Bauchi, Borno, Gombe and Kebbi - states are expected to announce their plans soon.