Assuming a link between routers in my AS fails and now I have two groups of routers not connected with each other. Each group is connected to a different AS through one of the routers. Will BGP find a possible route between them? Or it will refuse to re-route because it creates a loop (based on rejecting advertisements with its own ASN in AS path)?
If i understand correctly:
Will BGP find a possible route between them?
Withing your AS if you have link redundancy and the peering IP is reachable via IGP then you shouldn't have an issue.
If by this you mean to routing traffic from one group to the other through the ISP there shouldn't be an issue as well as long the ISP is aware that certain routes are not available over the interface where it is receiving it, so if you are advertising for example a /16 summary then you will probably have issues as the ISP will determine in it's table that the shortest path to that network is directly connected.
Or it will refuse to re-route because it creates a loop (based on rejecting advertisements with its own ASN in AS path)?
In regards to route advertising you will definitely have an issue, as a route that is received with it's own AS will be dropped due to loop unless an admin does some manual configuration as for example AS overwriting.
If I understand your question (or the question behind the question), you want to know if you can use your two ISPs to create a backup link between your two locations in case your primary link fails.
The answer is Yes with a couple of caveats, but BGP is probably not what you're looking for.
One idea is to create a tunnel (you will probably want to encrypt it with IPsec) between the external interfaces of your border routers. You can run your IGP in the tunnel and adjust your metrics so that tunnel is less preferred than any of your internal links. Should your internal link fail, the tunnel will be used to connect your locations.
You should consider what kind of bandwidth will be required if the tunnel is used, and apply QoS as needed so that you don't oversubscribe the tunnel capacity. Also consider if the tunnel MTU might cause problems and adjust accordingly.