Tredz and Wheelies are based in South Wales, and employ around 250 people across the UK. Keith Jones and his senior team will continue to manage the businesses "on a standalone basis"
The two businesses generated revenue of around £32m for the year ended 29 February, and EBITDA of £2.4m.
The deal has been settled using Halford's existing borrowing facilities. The acquisition will be earnings enhancing from the first year of ownership, the bike group said.
Halfords chief executive Jill McDonald said: "We are delighted with this acquisition, which we believe is a strong and complementary addition to the group, extending our presence in the online market for premium bikes, parts, accessories and clothing. We continue to believe in the long-term growth potential of the cycling market.
"Keith and his management team have done a fantastic job of building a successful online retail operation and we look forward to working with them to develop and grow the businesses further."
Jones added: "We are very proud of the businesses that we've grown from a small shop 27 years ago into a strong operator in the premium cycling market, with a team of over 250 people. However, the time has come for us to work with a partner on the next phase of growth.
"Halfords is exactly what we were looking for. With the support and resources of a large group, we look forward to building upon what we have achieved so far to drive long-term growth."