OSPF vs BGP route of the same

If a router is learning a route from OSPF and the same route via BGP which one wins? Mikrotik will not install the BGP route into the table will it? At what level does this happen? “Who” determines the behavior? OSPF or BGP or..?

All routes learned will be installed. If they are used is a mater of best path evaluation.

instance settings will let you influence all metrics and such but I’m afraid this is a whole other horse read up on OSPF and BGP then will we all be happy to discuss Mikrotik implementation of such.

https://wiki.mikrotik.com/wiki/Manual:Route_Selection_Algorithm_in_RouterOS

BGP routes come in two flavors: eBGP (peer has different ASN) and iBGP (peer has same ASN).

EBGP has a default administrative distance of 20
OSPF has a default administrative distance of 110
IBGP has a default administrative distance of 200

These are in keeping with Cisco (and I assume other major vendors use these settings too).

So EBGP routes will win over OSPF which will win over IBGP.
Note that BGP and OSPF have their own internal decision making routines which select the best route for any given prefix within their databases. The best BGP path (which will be either EBGP or IBGP, never both at the same time unless you use multiple BGP instances) will have distance=20 or 200. The best OSPF will have distance 110. Of the two, whichever has the lowest distance will be chosen as the active route for the destination.

Typically, you won’t see the same prefix in both OSPF and EBGP due to the fact that OSPF is an interior routing protocol, and EBGP is an exterior protocol - thus the prefixes in EBGP will be prefixes learned from the Internet where OSPF and your own originated prefixes will typically be found in IBGP. I’m not 100% certain whether locally-originated prefixes are consiidered to be iBGP or eBGP but I would think it’s iBGP since BGP should only originate prefixes that it sees as active in the routing table by other sources (such as OSPF, static, RIP, or connected routes).