The Blues - promoted straight back to the Premier League - will pay £2.65m for the former Hibernian striker.
O'Connor had earlier told BBC Sport: "It would be a dream to play in what I think is the best league in the world."
Birmingham had an offer of £1m rejected in January - and a further offer of £2m was also recently turned down.
Lokomotiv are believed to have wanted a one-off payment for the striker.
A statement on the club's website said: "Lokomotiv FC wishes to thank the striker for his high professionalism, hard work on the field and for the goal in the Russian Cup final."
Birmingham boss Steve Bruce is keen to bolster his attack ahead of the new season back in the Premier League.
The club are back in the top flight after a one-season absence and Bruce wants to avoid the goalscoring problems his side suffered when they were relegated in 2005/2006.
Birmingham scored only 28 league goals and had the least number of away goals - with a tally of nine - of all the Premier League sides from that campaign.
Bruce has had a bid rejected for West Ham's out-of-favour forward Marlon Harewood.
Fulham, Everton and Portsmouth had also been linked with O'Connor, who scored 58 goals in 166 appearances for Hibs before moving to Moscow 15 months ago.
O'Connor has been in good form recently, scoring in Lokomotiv's victory in the Russian Cup final.
He went on to score the only goal in Scotland's friendly victory over Austria - and was on target again in the 2-0 Euro 2008 qualifying win in the Faroe Islands.
Source:http://news.bbc.co.uk/sport2/hi/football/teams/b/birmingham_city/6231588.stm
Posted: at | |